Merge pull request #37 from konopackim/dev

Fixes and console interpreter
dev-ui
Piotr Dziwiński 2012-08-13 08:46:03 -07:00
commit dc3cadd309
110 changed files with 2232 additions and 4453 deletions

File diff suppressed because it is too large Load Diff

View File

@ -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)
@ -105,18 +105,18 @@ public:
bool StackOver();
/**
* \brief GivError Get error number of the stack
* \brief GetError Get error number of the stack
* \param [out] start beginning of the stack
* \param [out] end end of stack
* \return error number
*/
int GivError(int& start, int& end);
int GetError(int& start, int& end);
/**
* \brief GivError Get error number
* \brief GetError Get error number
* \return eror number
*/
int GivError();// rend le numéro d'erreur retourné
int GetError();// rend le numéro d'erreur retourné
/**
* \brief Reset Reset error at and set user
@ -131,18 +131,18 @@ public:
void SetType(CBotTypResult& type);
/**
* \brief GivType Get the type of value on the stack.
* \brief GetType Get the type of value on the stack.
* \param [in] mode Used when getting class type (1 gives pointer, 2 gives intrinsic).
* \return Type number.
*/
int GivType(int mode = 0);
int GetType(int mode = 0);
/**
* \brief Gives the type of complete value on the stack.
* \brief Getes the type of complete value on the stack.
* \param [in] mode Used when getting class type (1 gives pointer, 2 gives intrinsic).
* \return Type of an element.
*/
CBotTypResult GivTypResult(int mode = 0);
CBotTypResult GetTypResult(int mode = 0);
/**
* \brief Adds a local variable.
@ -215,18 +215,18 @@ public:
bool IsOk();
bool SetState(int n, int lim = -10); // select a state
int GivState(); // in what state am I?
int GetState(); // in what state am I?
bool IncState(int lim = -10); // passes to the next state
bool IfStep(); // do step by step
bool Execute();
void SetVar( CBotVar* var );
void SetCopyVar( CBotVar* var );
CBotVar* GivVar();
CBotVar* GivCopyVar();
CBotVar* GivPtVar();
bool GivRetVar(bool bRet);
long GivVal();
CBotVar* GetVar();
CBotVar* GetCopyVar();
CBotVar* GetPtVar();
bool GetRetVar(bool bRet);
long GetVal();
void SetStartError(int pos);
void SetError(int n, CBotToken* token = NULL);
@ -235,9 +235,9 @@ public:
void SetBreak(int val, const char* name);
void SetBotCall(CBotProgram* p);
CBotProgram* GivBotCall(bool bFirst = false);
void* GivPUser();
bool GivBlock();
CBotProgram* GetBotCall(bool bFirst = false);
void* GetPUser();
bool GetBlock();
bool ExecuteCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotTypResult& rettype);
@ -250,7 +250,7 @@ public:
void SetTimer(int n);
void GetRunPos(const char* &FunctionName, int &start, int &end);
CBotVar* GivStackVars(const char* &FunctionName, int level);
CBotVar* GetStackVars(const char* &FunctionName, int level);
int m_temp;
@ -301,12 +301,12 @@ inline bool CBotStack::IsOk()
return (m_error == 0);
}
inline int CBotStack::GivState()
inline int CBotStack::GetState()
{
return m_state;
}
inline int CBotStack::GivError()
inline int CBotStack::GetError()
{
return m_error;
}
@ -343,14 +343,14 @@ public:
~CBotCStack();
bool IsOk();
int GivError();
int GivError(int& start, int& end);
int GetError();
int GetError(int& start, int& end);
// gives error number
void SetType(CBotTypResult& type);// determines the type
CBotTypResult GivTypResult(int mode = 0); // gives the type of value on the stack
int GivType(int mode = 0); // gives the type of value on the stack
CBotClass* GivClass(); // gives the class of the value on the stack
CBotTypResult GetTypResult(int mode = 0); // gives the type of value on the stack
int GetType(int mode = 0); // gives the type of value on the stack
CBotClass* GetClass(); // gives the class of the value on the stack
void AddVar(CBotVar* p); // adds a local variable
CBotVar* FindVar(CBotToken* &p); // finds a variable
@ -364,7 +364,7 @@ public:
void SetVar( CBotVar* var );
void SetCopyVar( CBotVar* var );
CBotVar* GivVar();
CBotVar* GetVar();
void SetStartError(int pos);
void SetError(int n, int pos);
@ -372,11 +372,11 @@ public:
void ResetError(int n, int start, int end);
void SetRetType(CBotTypResult& type);
CBotTypResult GivRetType();
CBotTypResult GetRetType();
// void SetBotCall(CBotFunction* &pFunc);
void SetBotCall(CBotProgram* p);
CBotProgram* GivBotCall();
CBotProgram* GetBotCall();
CBotTypResult CompileCall(CBotToken* &p, CBotVar** ppVars, long& nIdent);
bool CheckCall(CBotToken* &pToken, CBotDefParam* pParam);
@ -454,15 +454,15 @@ public:
bool CompCase(CBotStack* &pj, int val);
void SetToken(CBotToken* p);
int GivTokenType();
CBotToken* GivToken();
int GetTokenType();
CBotToken* GetToken();
void AddNext(CBotInstr* n);
CBotInstr* GivNext();
CBotInstr* GetNext();
void AddNext3(CBotInstr* n);
CBotInstr* GivNext3();
CBotInstr* GetNext3();
void AddNext3b(CBotInstr* n);
CBotInstr* GivNext3b();
CBotInstr* GetNext3b();
static
void IncLvl(CBotString& label);
@ -1263,9 +1263,9 @@ public:
void SetValInt(int val, const char* s = NULL);
void SetValFloat(float val);
int GivValInt();
float GivValFloat();
CBotString GivValString();
int GetValInt();
float GetValFloat();
CBotString GetValString();
void Copy(CBotVar* pSrc, bool bName=true);
@ -1314,9 +1314,9 @@ public:
void SetValInt(int val, const char* s = NULL);
void SetValFloat(float val);
int GivValInt();
float GivValFloat();
CBotString GivValString();
int GetValInt();
float GetValFloat();
CBotString GetValString();
void Copy(CBotVar* pSrc, bool bName=true);
@ -1354,7 +1354,7 @@ public:
// ~CBotVarString();
void SetValString(const char* p);
CBotString GivValString();
CBotString GetValString();
void Copy(CBotVar* pSrc, bool bName=true);
@ -1382,9 +1382,9 @@ public:
void SetValInt(int val, const char* s = NULL);
void SetValFloat(float val);
int GivValInt();
float GivValFloat();
CBotString GivValString();
int GetValInt();
float GetValFloat();
CBotString GetValString();
void Copy(CBotVar* pSrc, bool bName=true);
@ -1426,14 +1426,14 @@ public:
void Copy(CBotVar* pSrc, bool bName=true);
void SetClass(CBotClass* pClass); //, int &nIdent);
CBotClass* GivClass();
CBotVar* GivItem(const char* name); // return an element of a class according to its name (*)
CBotVar* GivItemRef(int nIdent);
CBotClass* GetClass();
CBotVar* GetItem(const char* name); // return an element of a class according to its name (*)
CBotVar* GetItemRef(int nIdent);
CBotVar* GivItem(int n, bool bExtend);
CBotVar* GivItemList();
CBotVar* GetItem(int n, bool bExtend);
CBotVar* GetItemList();
CBotString GivValString();
CBotString GetValString();
bool Save1State(FILE* pf);
void Maj(void* pUser, bool bContinue);
@ -1442,7 +1442,7 @@ public:
void DecrementUse(); // a reference to decrementation
CBotVarClass*
GivPointer();
GetPointer();
void SetItemList(CBotVar* pVar);
void SetIdent(long n);
@ -1450,7 +1450,7 @@ public:
static CBotVarClass* Find(long id);
// CBotVar* GivMyThis();
// CBotVar* GetMyThis();
bool Eq(CBotVar* left, CBotVar* right);
bool Ne(CBotVar* left, CBotVar* right);
@ -1474,18 +1474,18 @@ public:
void Copy(CBotVar* pSrc, bool bName=true);
void SetClass(CBotClass* pClass);
CBotClass* GivClass();
CBotVar* GivItem(const char* name); // return an element of a class according to its name (*)
CBotVar* GivItemRef(int nIdent);
CBotVar* GivItemList();
CBotClass* GetClass();
CBotVar* GetItem(const char* name); // return an element of a class according to its name (*)
CBotVar* GetItemRef(int nIdent);
CBotVar* GetItemList();
CBotString GivValString();
CBotString GetValString();
void SetPointer(CBotVar* p);
CBotVarClass*
GivPointer();
GetPointer();
void SetIdent(long n); // associates an identification number (unique)
long GivIdent(); // gives the identification number associated with
long GetIdent(); // gives the identification number associated with
void ConstructorSet();
bool Save1State(FILE* pf);
@ -1514,15 +1514,15 @@ public:
void SetPointer(CBotVar* p);
CBotVarClass*
GivPointer();
GetPointer();
void Copy(CBotVar* pSrc, bool bName=true);
CBotVar* GivItem(int n, bool bGrow=false); // makes an element according to its numeric index
CBotVar* GetItem(int n, bool bGrow=false); // makes an element according to its numeric index
// enlarged the table if necessary if bExtend
// CBotVar* GivItem(const char* name); // makes a element by literal index
CBotVar* GivItemList(); // gives the first item in the list
// CBotVar* GetItem(const char* name); // makes a element by literal index
CBotVar* GetItemList(); // gives the first item in the list
CBotString GivValString(); // gets the contents of the array into a string
CBotString GetValString(); // gets the contents of the array into a string
bool Save1State(FILE* pf);
};
@ -1544,7 +1544,7 @@ extern bool ReadString(FILE* pf, CBotString& s);
extern bool WriteType(FILE* pf, CBotTypResult type);
extern bool ReadType(FILE* pf, CBotTypResult& type);
extern float GivNumFloat( const char* p );
extern float GetNumFloat( const char* p );
#if false
extern void DEBUG( const char* text, int val, CBotStack* pile );
@ -1596,7 +1596,7 @@ public:
bool RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotStack* pStack);
#endif
CBotString GivName();
CBotString GetName();
CBotCall* Next();
static void SetPUser(void* pUser);
@ -1629,7 +1629,7 @@ public:
int DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotVar* &pResult, CBotStack* pStack, CBotToken* pFunc);
CBotString GivName();
CBotString GetName();
CBotCallMethode* Next();
void AddNext(CBotCallMethode* p);
@ -1655,11 +1655,11 @@ public:
void RestoreState(CBotStack* &pj, bool bMain);
void AddNext(CBotDefParam* p);
int GivType();
CBotTypResult GivTypResult();
CBotDefParam* GivNext();
int GetType();
CBotTypResult GetTypResult();
CBotDefParam* GetNext();
CBotString GivParamString();
CBotString GetParamString();
};
@ -1720,8 +1720,8 @@ public:
static
void AddPublic(CBotFunction* pfunc);
CBotString GivName();
CBotString GivParams();
CBotString GetName();
CBotString GetParams();
bool IsPublic();
bool IsExtern();
CBotFunction* Next();

View File

@ -175,7 +175,7 @@ void CBotClass::FreeLock(CBotProgram* p)
bool CBotClass::AddItem(CBotString name, CBotTypResult type, int mPrivate)
{
CBotToken token(name, CBotString());
CBotClass* pClass = type.GivClass();
CBotClass* pClass = type.GetClass();
CBotVar* pVar = CBotVar::Create( name, type );
/// pVar->SetUniqNum(CBotVar::NextUniqNum());
@ -188,7 +188,7 @@ bool CBotClass::AddItem(CBotString name, CBotTypResult type, int mPrivate)
{
// adds a new statement for the object initialization
pVar->m_InitExpr = new CBotNew() ;
CBotToken nom( pClass->GivName() );
CBotToken nom( pClass->GetName() );
pVar->m_InitExpr->SetToken(&nom);
}
}
@ -214,12 +214,12 @@ void CBotClass::AddNext(CBotClass* pClass)
p->m_next = pClass;
}
CBotString CBotClass::GivName()
CBotString CBotClass::GetName()
{
return m_name;
}
CBotClass* CBotClass::GivParent()
CBotClass* CBotClass::GetParent()
{
if ( this == NULL ) return NULL;
return m_pParent;
@ -237,34 +237,34 @@ bool CBotClass::IsChildOf(CBotClass* pClass)
}
CBotVar* CBotClass::GivVar()
CBotVar* CBotClass::GetVar()
{
return m_pVar;
}
CBotVar* CBotClass::GivItem(const char* name)
CBotVar* CBotClass::GetItem(const char* name)
{
CBotVar* p = m_pVar;
while ( p != NULL )
{
if ( p->GivName() == name ) return p;
p = p->GivNext();
if ( p->GetName() == name ) return p;
p = p->GetNext();
}
if ( m_pParent != NULL ) return m_pParent->GivItem(name);
if ( m_pParent != NULL ) return m_pParent->GetItem(name);
return NULL;
}
CBotVar* CBotClass::GivItemRef(int nIdent)
CBotVar* CBotClass::GetItemRef(int nIdent)
{
CBotVar* p = m_pVar;
while ( p != NULL )
{
if ( p->GivUniqNum() == nIdent ) return p;
p = p->GivNext();
if ( p->GetUniqNum() == nIdent ) return p;
p = p->GetNext();
}
if ( m_pParent != NULL ) return m_pParent->GivItemRef(nIdent);
if ( m_pParent != NULL ) return m_pParent->GetItemRef(nIdent);
return NULL;
}
@ -275,7 +275,7 @@ bool CBotClass::IsIntrinsic()
CBotClass* CBotClass::Find(CBotToken* &pToken)
{
return Find(pToken->GivString());
return Find(pToken->GetString());
}
CBotClass* CBotClass::Find(const char* name)
@ -284,7 +284,7 @@ CBotClass* CBotClass::Find(const char* name)
while ( p != NULL )
{
if ( p->GivName() == name ) return p;
if ( p->GetName() == name ) return p;
p = p->m_ExNext;
}
@ -301,7 +301,7 @@ bool CBotClass::AddFunction(const char* name,
while ( p != NULL )
{
if ( name == p->GivName() )
if ( name == p->GetName() )
{
if ( pp == NULL ) m_pCalls = p->m_next;
else pp->m_next = p->m_next;
@ -338,7 +338,7 @@ CBotTypResult CBotClass::CompileMethode(const char* name,
// find the methods declared by AddFunction
CBotTypResult r = m_pCalls->CompileCall(name, pThis, ppParams, pStack, nIdent);
if ( r.GivType() >= 0) return r;
if ( r.GetType() >= 0) return r;
// find the methods declared by user
@ -384,21 +384,21 @@ bool CBotClass::SaveStaticState(FILE* pf)
{
if (!WriteWord( pf, 1)) return false;
// save the name of the class
if (!WriteString( pf, p->GivName() )) return false;
if (!WriteString( pf, p->GetName() )) return false;
CBotVar* pv = p->GivVar();
CBotVar* pv = p->GetVar();
while( pv != NULL )
{
if ( pv->IsStatic() )
{
if (!WriteWord( pf, 1)) return false;
if (!WriteString( pf, pv->GivName() )) return false;
if (!WriteString( pf, pv->GetName() )) return false;
if ( !pv->Save0State(pf)) return false; // common header
if ( !pv->Save1State(pf) ) return false; // saves as the child class
if ( !WriteWord( pf, 0)) return false;
}
pv = pv->GivNext();
pv = pv->GetNext();
}
if (!WriteWord( pf, 0)) return false;
@ -435,7 +435,7 @@ bool CBotClass::RestoreStaticState(FILE* pf)
CBotVar* pv = NULL;
if (!ReadString( pf, VarName )) return false;
if ( pClass != NULL ) pVar = pClass->GivItem(VarName);
if ( pClass != NULL ) pVar = pClass->GetItem(VarName);
if (!CBotVar::RestoreState(pf, pv)) return false; // the temp variable
@ -475,7 +475,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
// seeks the corresponding classes
if ( pClass == NULL )
{
pStack->SetStartError(p->GivStart());
pStack->SetStartError(p->GetStart());
pClass = CBotClass::Find(p);
if ( pClass == NULL )
{
@ -483,29 +483,29 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
pStack->SetError(TX_NOCLASS, p);
return NULL;
}
p = p->GivNext();
p = p->GetNext();
}
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();
inst = new CBotClassInst();
/// \TODO Need to be revised and fixed after adding unit tests
CBotToken token(pClass->GivName(), CBotString(), p->GivStart(), p->GivEnd());
CBotToken token(pClass->GetName(), CBotString(), p->GetStart(), p->GetEnd());
inst->SetToken(&token);
CBotToken* vartoken = p;
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->GivStart());
pStk->SetError(TX_REDEFVAR, vartoken->GivEnd());
pStk->SetStartError(vartoken->GetStart());
pStk->SetError(TX_REDEFVAR, vartoken->GetEnd());
goto error;
}
@ -516,11 +516,11 @@ 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() )
{
pStk->SetError(TX_CLBRK, p->GivStart());
pStk->SetError(TX_CLBRK, p->GetStart());
goto error;
}
goto suite; // no assignment, variable already created
@ -528,15 +528,15 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
CBotVar* var;
var = CBotVar::Create(vartoken->GivString(), type); // creates the instance
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
// look if there are parameters
inst->m_hasParams = (p->GivType() == ID_OPENPAR);
inst->m_hasParams = (p->GetType() == ID_OPENPAR);
CBotVar* ppVars[1000];
inst->m_Parameters = CompileParams(p, pStk, ppVars);
@ -551,9 +551,9 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
{
// the constructor is there?
// CBotString noname;
CBotTypResult r = pClass->CompileMethode(pClass->GivName(), var, ppVars, pStk, inst->m_nMethodeIdent);
CBotTypResult r = pClass->CompileMethode(pClass->GetName(), var, ppVars, pStk, inst->m_nMethodeIdent);
delete pStk->TokenStack(); // releases the supplement stack
int typ = r.GivType();
int typ = r.GetType();
if (typ == TX_UNDEFCALL)
{
@ -568,7 +568,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
if (typ>20)
{
pStk->SetError(typ, vartoken->GivEnd());
pStk->SetError(typ, vartoken->GetEnd());
goto error;
}
@ -578,7 +578,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
{
if (inst->m_hasParams)
{
pStk->SetError(TX_ENDOF, p->GivStart());
pStk->SetError(TX_ENDOF, p->GetStart());
goto error;
}
@ -586,15 +586,15 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
{
goto error;
}
CBotClass* result = pStk->GivClass();
if ( !pStk->GivTypResult(1).Eq(CBotTypNullPointer) &&
( !pStk->GivTypResult(1).Eq(CBotTypPointer) ||
CBotClass* result = pStk->GetClass();
if ( !pStk->GetTypResult(1).Eq(CBotTypNullPointer) &&
( !pStk->GetTypResult(1).Eq(CBotTypPointer) ||
( result != NULL && !pClass->IsChildOf(result) ))) // type compatible ?
{
pStk->SetError(TX_BADTYPE, p->GivStart());
pStk->SetError(TX_BADTYPE, p->GetStart());
goto error;
}
// if ( !bIntrinsic ) var->SetPointer(pStk->GivVar()->GivPointer());
// if ( !bIntrinsic ) var->SetPointer(pStk->GetVar()->GetPointer());
if ( !bIntrinsic )
{
// does not use the result on the stack, to impose the class
@ -630,7 +630,7 @@ suite:
return pStack->Return(inst, pStk);
}
pStk->SetError(TX_ENDOF, p->GivStart());
pStk->SetError(TX_ENDOF, p->GetStart());
}
error:
@ -655,9 +655,9 @@ bool CBotClassInst::Execute(CBotStack* &pj)
// creates the variable of type pointer to the object
if ( pile->GivState()==0)
if ( pile->GetState()==0)
{
CBotString name = m_var->m_token.GivString();
CBotString name = m_var->m_token.GetString();
if ( bIntrincic )
{
pThis = CBotVar::Create(name, CBotTypResult( CBotTypIntrinsic, pClass ));
@ -667,14 +667,14 @@ 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->GivState()<3)
if ( pile->GetState()<3)
{
// ss there an assignment or parameters (contructor)
@ -687,18 +687,18 @@ bool CBotClassInst::Execute(CBotStack* &pj)
if ( bIntrincic )
{
CBotVar* pv = pile->GivVar();
if ( pv == NULL || pv->GivPointer() == NULL )
CBotVar* pv = pile->GetVar();
if ( pv == NULL || pv->GetPointer() == NULL )
{
pile->SetError(TX_NULLPT, &m_token);
return pj->Return(pile);
}
pThis->Copy(pile->GivVar(), false);
pThis->Copy(pile->GetVar(), false);
}
else
{
CBotVarClass* pInstance;
pInstance = ((CBotVarPointer*)pile->GivVar())->GivPointer(); // value for the assignment
pInstance = (static_cast<CBotVarPointer*>(pile->GetVar()))->GetPointer(); // value for the assignment
pThis->SetPointer(pInstance);
}
pThis->SetInit(true);
@ -708,7 +708,7 @@ bool CBotClassInst::Execute(CBotStack* &pj)
{
// evaluates the constructor of an instance
if ( !bIntrincic && pile->GivState() == 1)
if ( !bIntrincic && pile->GetState() == 1)
{
CBotToken* pt = &m_token;
CBotClass* pClass = CBotClass::Find(pt);
@ -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;
@ -736,13 +736,13 @@ bool CBotClassInst::Execute(CBotStack* &pj)
if ( p != NULL) while ( true )
{
pile2 = pile2->AddStack(); // place on the stack for the results
if ( pile2->GivState() == 0 )
if ( pile2->GetState() == 0 )
{
if (!p->Execute(pile2)) return false; // interrupted here?
pile2->SetState(1);
}
ppVars[i++] = pile2->GivVar();
p = p->GivNext();
ppVars[i++] = pile2->GetVar();
p = p->GetNext();
if ( p == NULL) break;
}
ppVars[i] = NULL;
@ -750,15 +750,15 @@ bool CBotClassInst::Execute(CBotStack* &pj)
// creates a variable for the result
CBotVar* pResult = NULL; // constructor still void
if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GivName(),
if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GetName(),
pThis, ppVars,
pResult, pile2, GivToken())) return false; // interrupt
pResult, pile2, GetToken())) return false; // interrupt
pThis->SetInit(true);
pThis->ConstructorSet(); // indicates that the constructor has been called
pile->Return(pile2); // releases a piece of stack
// pInstance = pThis->GivPointer();
// pInstance = pThis->GetPointer();
}
@ -787,16 +787,16 @@ void CBotClassInst::RestoreState(CBotStack* &pj, bool bMain)
// creates the variable of type pointer to the object
{
CBotString name = m_var->m_token.GivString();
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;
CBotClass* pClass = CBotClass::Find(pt);
bool bIntrincic = pClass->IsIntrinsic();
if ( bMain && pile->GivState()<3)
if ( bMain && pile->GetState()<3)
{
// is there an assignment or parameters (constructor)
@ -813,7 +813,7 @@ void CBotClassInst::RestoreState(CBotStack* &pj, bool bMain)
{
// evaluates the constructor of an instance
if ( !bIntrincic && pile->GivState() == 1)
if ( !bIntrincic && pile->GetState() == 1)
{
return;
}
@ -833,21 +833,21 @@ void CBotClassInst::RestoreState(CBotStack* &pj, bool bMain)
pile2 = pile2->RestoreStack(); // place on the stack for the results
if ( pile2 == NULL ) return;
if ( pile2->GivState() == 0 )
if ( pile2->GetState() == 0 )
{
p->RestoreState(pile2, bMain); // interrupted here?
return;
}
ppVars[i++] = pile2->GivVar();
p = p->GivNext();
ppVars[i++] = pile2->GetVar();
p = p->GetNext();
if ( p == NULL) break;
}
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->GivName(), pThis, ppVars, pile2);
pClass->RestoreMethode(m_nMethodeIdent, pClass->GetName(), pThis, ppVars, pile2);
return;
}
}
@ -861,14 +861,14 @@ void CBotClassInst::RestoreState(CBotStack* &pj, bool bMain)
bool CBotClass::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
{
CBotString name = pToken->GivString();
CBotString name = pToken->GetString();
if ( CBotCall::CheckCall(name) ) return true;
CBotFunction* pp = m_pMethod;
while ( pp != NULL )
{
if ( pToken->GivString() == pp->GivName() )
if ( pToken->GetString() == pp->GetName() )
{
// are their parameters exactly the same?
if ( pp->CheckParam( pParam ) )

View File

@ -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*/
@ -111,16 +112,16 @@ public:
~CBotTypResult();
int GivType(int mode = 0) const;
int GetType(int mode = 0) const;
// returns type CBotType* as a result
void SetType(int n);
// modifies a type
CBotClass* GivClass() const;
CBotClass* GetClass() const;
// makes the pointer to the class (for CBotTypClass, CBotTypPointer)
int GivLimite() const;
int GetLimite() const;
// returns limit size of table (CBotTypArray)
void SetLimite(int n);
@ -129,7 +130,7 @@ public:
void SetArray(int* max );
// set limits for a list of dimensions (arrays of arrays)
CBotTypResult& GivTypElem() const;
CBotTypResult& GetTypElem() const;
// returns type of array elements (CBotTypArray)
// rend le type des éléments du tableau (CBotTypArray)
@ -262,7 +263,7 @@ public:
void Empty();
bool IsEmpty() const;
int GivLength();
int GetLength();
int Find(const char c);
int Find(const char* lpsz);
int ReverseFind(const char c);
@ -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
@ -338,7 +339,7 @@ public:
CBotStringArray();
~CBotStringArray();
void SetSize(int nb);
int GivSize();
int GetSize();
void Add(const CBotString& str);
CBotString& operator[](int nIndex);
@ -388,7 +389,7 @@ public:
// frees the static memory areas
static
int GivVersion();
int GetVersion();
// gives the version of the library CBOT
@ -406,10 +407,10 @@ public:
void SetIdent(long n);
// associates an identifier with the instance CBotProgram
long GivIdent();
long GetIdent();
// gives the identifier
int GivError();
int GetError();
bool GetError(int& code, int& start, int& end);
bool GetError(int& code, int& start, int& end, CBotProgram* &pProg);
// if true
@ -417,7 +418,7 @@ public:
// or execution
// delimits the start and end block where the error
// pProg lets you know what "module" has produced runtime error
static CBotString GivErrorText(int code);
static CBotString GetErrorText(int code);
bool Start(const char* name);
@ -437,7 +438,7 @@ public:
// FunctionName is a pointer made to the name of the function
// start and end position in the text of the token processing
CBotVar* GivStackVars(const char* &FunctionName, int level);
CBotVar* GetStackVars(const char* &FunctionName, int level);
// provides the pointer to the variables on the execution stack
// level is an input parameter, 0 for the last level, -1, -2, etc. for the other levels
// the return value (CBotVar *) is a variable list (or NULL)
@ -480,7 +481,7 @@ public:
// see the above modes in CBotGet
CBotFunction* GivFunctions();
CBotFunction* GetFunctions();
};
@ -513,8 +514,8 @@ int cMean(CBotVar* &pVar, CBotString& ClassName)
while ( pVar != NULL )
{
if ( pVar->GivType() > CBotTypDouble ) return 6002; // this is not a number
pVar = pVar -> GivNext();
if ( pVar->GetType() > CBotTypDouble ) return 6002; // this is not a number
pVar = pVar -> GetNext();
}
return CBotTypFloat; // the type of the result may depend on the parameters!
@ -527,8 +528,8 @@ bool rMean(CBotVar* pVar, CBotVar* pResult, int& Exception)
int nb = 0;
while (pVar != NULL)
{
total += pVar->GivValFloat();
pVar = pVar->GivNext();
total += pVar->GetValFloat();
pVar = pVar->GetNext();
nb++;
}
pResult->SetValFloat(total/nb); // returns the mean value
@ -544,7 +545,7 @@ bool rMean(CBotVar* pVar, CBotVar* pResult, int& Exception)
// may be useful to the outside of the module
// ( it is currently not expected to be able to create these objects in outer )
// results of GivInit()
// results of GetInit()
#define IS_UNDEF 0 // undefined variable
#define IS_DEF 1 // variable defined
#define IS_NAN 999 // variable defined as not a number
@ -615,33 +616,33 @@ virtual ~CBotVar( ); // destructor
// associates a unique identifier to an instance
// ( it is used to ensure that the id is unique)
void* GivUserPtr();
void* GetUserPtr();
// makes the pointer associated with the variable
CBotString GivName(); // the name of the variable, if known
CBotString GetName(); // the name of the variable, if known
////////////////////////////////////////////////////////////////////////////////////
void SetName(const char* name); // changes the name of the variable
int GivType(int mode = 0); // returns the base type (int) of the variable
int GetType(int mode = 0); // returns the base type (int) of the variable
// TODO check it
////////////////////////////////////////////////////////////////////////////////////////
CBotTypResult GivTypResult(int mode = 0); // returns the complete type of the variable
CBotTypResult GetTypResult(int mode = 0); // returns the complete type of the variable
CBotToken* GivToken();
CBotToken* GetToken();
void SetType(CBotTypResult& type);
void SetInit(int bInit); // is the variable in the state IS_UNDEF, IS_DEF, IS_NAN
int GivInit(); // gives the state of the variable
int GetInit(); // gives the state of the variable
void SetStatic(bool bStatic);
bool IsStatic();
void SetPrivate(int mPrivate);
bool IsPrivate(int mode = PR_PROTECT);
int GivPrivate();
int GetPrivate();
virtual
void ConstructorSet();
@ -649,23 +650,23 @@ virtual ~CBotVar( ); // destructor
void SetVal(CBotVar* var); // remprend une valeur
// TODO remprend value
virtual
CBotVar* GivItem(const char* name); // returns an element of a class according to its name (*)
CBotVar* GetItem(const char* name); // returns an element of a class according to its name (*)
virtual
CBotVar* GivItemRef(int nIdent); // idem à partir du n° ref
CBotVar* GetItemRef(int nIdent); // idem à partir du n° ref
// TODO ditto from ref no.
virtual
CBotVar* GivItem(int row, bool bGrow = false);
CBotVar* GetItem(int row, bool bGrow = false);
virtual
CBotVar* GivItemList(); // lists the elements
CBotVar* GetItemList(); // lists the elements
CBotVar* GivStaticVar(); // makes the pointer to the variable if it is static
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* GivNext(); // next variable in the list (parameters)
CBotVar* GetNext(); // next variable in the list (parameters)
////////////////////////////////////////////////////////////////////////////////////////////
void AddNext(CBotVar* pVar); // added to a list
@ -683,23 +684,23 @@ virtual ~CBotVar( ); // destructor
virtual void SetValString(const char* p);// initialized with a string value (#)
////////////////////////////////////////////////////////////////////////////////
virtual int GivValInt(); // request the full value (#)
virtual int GetValInt(); // request the full value (#)
////////////////////////////////////////////////////////////////////////
virtual float GivValFloat(); // gets real value (#)
virtual float GetValFloat(); // gets real value (#)
///////////////////////////////////////////////////////////////////////
virtual
CBotString GivValString(); // request the string value (#)
CBotString GetValString(); // request the string value (#)
///////////////////////////////////////////////////////////////////////
virtual void SetClass(CBotClass* pClass);
virtual
CBotClass* GivClass();
CBotClass* GetClass();
virtual void SetPointer(CBotVar* p);
virtual
CBotVarClass* GivPointer();
CBotVarClass* GetPointer();
// virtual void SetIndirection(CBotVar* pVar);
virtual void Add(CBotVar* left, CBotVar* right); // addition
@ -736,13 +737,13 @@ virtual ~CBotVar( ); // destructor
void debug();
// virtual
// CBotVar* GivMyThis();
// CBotVar* GetMyThis();
virtual
void Maj(void* pUser = NULL, bool bContinue = true);
void SetUniqNum(long n);
long GivUniqNum();
long GetUniqNum();
static long NextUniqNum();
};
@ -751,12 +752,12 @@ virtual ~CBotVar( ); // destructor
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->GivType() == CBotInt() ) pVar->SetValFloat( 3.3 ); // plante !!
if ( pVar->GetType() == CBotInt() ) pVar->SetValFloat( 3.3 ); // plante !!
methods GivValInt(), GivValFloat() et GivValString()
methods GetValInt(), GetValFloat() et GetValString()
use value conversions,
GivValString() works on numbers (makes the corresponding string)
but do not make GivValInt () with a string variable!
GetValString() works on numbers (makes the corresponding string)
but do not make GetValInt () with a string variable!
*/
@ -824,8 +825,8 @@ public:
// adds an element by giving an element of type CBotVar
void AddNext(CBotClass* pClass);
CBotString GivName(); // gives the name of the class
CBotClass* GivParent(); // gives the parent class (or NULL)
CBotString GetName(); // gives the name of the class
CBotClass* GetParent(); // gives the parent class (or NULL)
// true if a class is derived (Extends) of another
// return true also if the classes are identical
@ -837,9 +838,9 @@ public:
static
CBotClass* Find(const char* name);
CBotVar* GivVar(); // return the list of variables
CBotVar* GivItem(const char* name); // one of the variables according to its name
CBotVar* GivItemRef(int nIdent);
CBotVar* GetVar(); // return the list of variables
CBotVar* GetItem(const char* name); // one of the variables according to its name
CBotVar* GetItemRef(int nIdent);
CBotTypResult CompileMethode(const char* name, CBotVar* pThis, CBotVar** ppParams,
CBotCStack* pStack, long& nIdent);
@ -922,9 +923,9 @@ private:
* \brief Check whether given parameter is a keyword
*/
static
int GivKeyWords(const char* w); // is it a keyword?
int GetKeyWords(const char* w); // is it a keyword?
static
bool GivKeyDefNum(const char* w, CBotToken* &token);
bool GetKeyDefNum(const char* w, CBotToken* &token);
/**
* \brief Loads the list of keywords
@ -948,35 +949,35 @@ public:
/**
* \brief Returns the type of token
*/
int GivType();
int GetType();
/**
* \brief makes the string corresponding to this token
*/
CBotString& GivString();
CBotString& GetString();
/**
* \brief makes the following separator token
*/
CBotString& GivSep();
CBotString& GetSep();
/**
* \brief position of the beginning in the text
*/
int GivStart();
int GetStart();
/**
* \brief end position in the text
*/
int GivEnd();
int GetEnd();
/**
* \brief gives the next token in the list
*/
CBotToken* GivNext();
CBotToken* GetNext();
/**
* \brief gives the previous token in a list
*/
CBotToken* GivPrev();
CBotToken* GetPrev();
/**
* \brief transforms the entire program
@ -997,7 +998,7 @@ public:
void SetString(const char* name);
void SetPos(int start, int end);
long GivIdKey();
long GetIdKey();
/**
* \brief adds a token (a copy)
*/
@ -1091,7 +1092,7 @@ public:
// routine that implements the GOTO (CPoint pos)
bool rDoGoto( CBotVar* pVar, CBotVar* pResult, int& exception )
{
if (pVar->GivType() != CBotTypeClass ||
if (pVar->GetType() != CBotTypeClass ||
pVar->IsElemOfClas("CPoint") ) { exception = 6522; return false; )
// the parameter is not the right class?
// in fact the control is done to the routine of compilation
@ -1100,13 +1101,13 @@ bool rDoGoto( CBotVar* pVar, CBotVar* pResult, int& exception )
// or so
CBotVar* temp;
temp = pVar->GivItem("x"); // is necessary for the object of type CPoint
ASSERT (temp != NULL && temp->GivType() == CBotTypFloat);
m_PosToGo.x = temp->GivValFloat();
temp = pVar->GetItem("x"); // is necessary for the object of type CPoint
ASSERT (temp != NULL && temp->GetType() == CBotTypFloat);
m_PosToGo.x = temp->GetValFloat();
temp = pVar->GivItem("y"); // is necessary for the object of type CPoint
ASSERT (temp != NULL && temp->GivType() == CBotTypFloat);
m_PosToGo.y = temp->GivValFloat();
temp = pVar->GetItem("y"); // is necessary for the object of type CPoint
ASSERT (temp != NULL && temp->GetType() == CBotTypFloat);
m_PosToGo.y = temp->GetValFloat();
return (m_CurentPos == m_PosToGo); // makes true if the position is reached
// returns false if one had wait yet

View File

@ -77,40 +77,40 @@ bool CBotFunction::IsExtern()
bool CBotFunction::GetPosition(int& start, int& stop, CBotGet modestart, CBotGet modestop)
{
start = m_extern.GivStart();
stop = m_closeblk.GivEnd();
start = m_extern.GetStart();
stop = m_closeblk.GetEnd();
if (modestart == GetPosExtern)
{
start = m_extern.GivStart();
start = m_extern.GetStart();
}
if (modestop == GetPosExtern)
{
stop = m_extern.GivEnd();
stop = m_extern.GetEnd();
}
if (modestart == GetPosNom)
{
start = m_token.GivStart();
start = m_token.GetStart();
}
if (modestop == GetPosNom)
{
stop = m_token.GivEnd();
stop = m_token.GetEnd();
}
if (modestart == GetPosParam)
{
start = m_openpar.GivStart();
start = m_openpar.GetStart();
}
if (modestop == GetPosParam)
{
stop = m_closepar.GivEnd();
stop = m_closepar.GetEnd();
}
if (modestart == GetPosBloc)
{
start = m_openblk.GivStart();
start = m_openblk.GetStart();
}
if (modestop == GetPosBloc)
{
stop = m_closeblk.GivEnd();
stop = m_closeblk.GetEnd();
}
return true;
@ -123,7 +123,7 @@ CBotTypResult ArrayType(CBotToken* &p, CBotCStack* pile, CBotTypResult type)
{
if ( !IsOfType( p, ID_CLBRK ) )
{
pile->SetError(TX_CLBRK, p->GivStart());
pile->SetError(TX_CLBRK, p->GetStart());
return CBotTypResult( -1 );
}
type = CBotTypResult( CBotTypArrayPointer, type );
@ -135,30 +135,30 @@ CBotTypResult TypeParam(CBotToken* &p, CBotCStack* pile)
{
CBotClass* pClass = NULL;
switch (p->GivType())
switch (p->GetType())
{
case ID_INT:
p = p->GivNext();
p = p->GetNext();
return ArrayType(p, pile, CBotTypResult( CBotTypInt ));
case ID_FLOAT:
p = p->GivNext();
p = p->GetNext();
return ArrayType(p, pile, CBotTypResult( CBotTypFloat ));
case ID_BOOLEAN:
case ID_BOOL:
p = p->GivNext();
p = p->GetNext();
return ArrayType(p, pile, CBotTypResult( CBotTypBoolean ));
case ID_STRING:
p = p->GivNext();
p = p->GetNext();
return ArrayType(p, pile, CBotTypResult( CBotTypString ));
case ID_VOID:
p = p->GivNext();
p = p->GetNext();
return CBotTypResult( 0 );
case TokenTypVar:
pClass = CBotClass::Find(p);
if ( pClass != NULL)
{
p = p->GivNext();
p = p->GetNext();
return ArrayType(p, pile,
pClass->IsIntrinsic() ?
CBotTypResult( CBotTypIntrinsic, pClass ) :
@ -203,14 +203,14 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
// CBotClass* pClass;
func->m_retTyp = TypeParam(p, pStk); // type of the result
if (func->m_retTyp.GivType() >= 0)
if (func->m_retTyp.GetType() >= 0)
{
CBotToken* pp = p;
func->m_token = *p;
if ( IsOfType(p, ID_NOT) )
{
CBotToken d("~" + p->GivString());
CBotToken d("~" + p->GetString());
func->m_token = d;
}
@ -219,7 +219,7 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
{
if ( IsOfType( p, ID_DBLDOTS ) ) // method for a class
{
func->m_MasterClass = pp->GivString();
func->m_MasterClass = pp->GetString();
CBotClass* pClass = CBotClass::Find(pp);
if ( pClass == NULL ) goto bad;
@ -230,7 +230,7 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
}
func->m_openpar = p;
func->m_Param = CBotDefParam::Compile( p, pStk );
func->m_closepar = p->GivPrev();
func->m_closepar = p->GetPrev();
if (pStk->IsOk())
{
pStk->SetRetType(func->m_retTyp); // for knowledge what type returns
@ -247,24 +247,24 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
// initialize variables acording to This
// only saves the pointer to the first,
// the rest is chained
CBotVar* pv = pThis->GivItemList();
CBotVar* pv = pThis->GetItemList();
// int num = 1;
while (pv != NULL)
{
CBotVar* pcopy = CBotVar::Create(pv);
// pcopy->SetInit(2);
pcopy->Copy(pv);
pcopy->SetPrivate(pv->GivPrivate());
// pcopy->SetUniqNum(pv->GivUniqNum()); //num++);
pcopy->SetPrivate(pv->GetPrivate());
// pcopy->SetUniqNum(pv->GetUniqNum()); //num++);
pStk->AddVar(pcopy);
pv = pv->GivNext();
pv = pv->GetNext();
}
}
// and compiles the following instruction block
func->m_openblk = p;
func->m_Block = CBotBlock::Compile(p, pStk, false);
func->m_closeblk = p->GivPrev();
func->m_closeblk = p->GetPrev();
if ( pStk->IsOk() )
{
if ( func->m_bPublic ) // public function, return known for all
@ -309,7 +309,7 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
func->m_retToken = *p;
func->m_retTyp = TypeParam(p, pStack); // type of the result
if (func->m_retTyp.GivType() >= 0)
if (func->m_retTyp.GetType() >= 0)
{
CBotToken* pp = p;
func->m_token = *p;
@ -318,7 +318,7 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
{
if ( IsOfType( p, ID_DBLDOTS ) ) // method for a class
{
func->m_MasterClass = pp->GivString();
func->m_MasterClass = pp->GetString();
CBotClass* pClass = CBotClass::Find(pp);
if ( pClass == NULL )
{
@ -344,8 +344,8 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
// and skips the following instruction block
do
{
int type = p->GivType();
p = p->GivNext();
int type = p->GetType();
p = p->GetNext();
if (type == ID_OPBLK) level++;
if (type == ID_CLBLK) level--;
}
@ -377,13 +377,13 @@ bool CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance)
pile->SetBotCall(m_pProg); // bases for routines
if ( pile->GivState() == 0 )
if ( pile->GetState() == 0 )
{
if ( !m_Param->Execute(ppVars, pile) ) return false; // define parameters
pile->IncState();
}
if ( pile->GivState() == 1 && !m_MasterClass.IsEmpty() )
if ( pile->GetState() == 1 && !m_MasterClass.IsEmpty() )
{
// makes "this" known
CBotVar* pThis ;
@ -410,7 +410,7 @@ bool CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance)
if ( !m_Block->Execute(pile) )
{
if ( pile->GivError() < 0 )
if ( pile->GetError() < 0 )
pile->SetError( 0 );
else
return false;
@ -428,11 +428,11 @@ void CBotFunction::RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInst
pile->SetBotCall(m_pProg); // bases for routines
if ( pile->GivBlock() < 2 )
if ( pile->GetBlock() < 2 )
{
CBotStack* pile2 = pile->RestoreStack(NULL); // one end of stack local to this function
if ( pile2 == NULL ) return;
pile->SetState(pile->GivState() + pile2->GivState());
pile->SetState(pile->GetState() + pile2->GetState());
pile2->Delete();
}
@ -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;
}
@ -507,7 +508,7 @@ CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CB
{
for ( pt = this ; pt != NULL ; pt = pt->m_next )
{
if ( pt->m_token.GivString() == name )
if ( pt->m_token.GetString() == name )
{
int i = 0;
int alpha = 0; // signature of parameters
@ -516,15 +517,15 @@ CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CB
CBotVar* pw = ppVars[i++]; // provided list parameter
while ( pv != NULL && pw != NULL)
{
if (!TypesCompatibles(pv->GivTypResult(), pw->GivTypResult()))
if (!TypesCompatibles(pv->GetTypResult(), pw->GetTypResult()))
{
if ( pFunc == NULL ) TypeOrError = TX_BADPARAM;
break;
}
int d = pv->GivType() - pw->GivType(2);
int d = pv->GetType() - pw->GetType(2);
alpha += d>0 ? d : -10*d; // quality loss, 10 times more expensive!
pv = pv->GivNext();
pv = pv->GetNext();
pw = ppVars[i++];
}
if ( pw != NULL )
@ -562,7 +563,7 @@ CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CB
{
for ( pt = m_listPublic ; pt != NULL ; pt = pt->m_nextpublic )
{
if ( pt->m_token.GivString() == name )
if ( pt->m_token.GetString() == name )
{
int i = 0;
int alpha = 0; // signature of parameters
@ -571,15 +572,15 @@ CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CB
CBotVar* pw = ppVars[i++]; // list of provided parameters
while ( pv != NULL && pw != NULL)
{
if (!TypesCompatibles(pv->GivTypResult(), pw->GivTypResult()))
if (!TypesCompatibles(pv->GetTypResult(), pw->GetTypResult()))
{
if ( pFunc == NULL ) TypeOrError = TX_BADPARAM;
break;
}
int d = pv->GivType() - pw->GivType(2);
int d = pv->GetType() - pw->GetType(2);
alpha += d>0 ? d : -10*d; // quality loss, 10 times more expensive!
pv = pv->GivNext();
pv = pv->GetNext();
pw = ppVars[i++];
}
if ( pw != NULL )
@ -645,7 +646,7 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar** ppVars, CBotS
// preparing parameters on the stack
if ( pStk1->GivState() == 0 )
if ( pStk1->GetState() == 0 )
{
if ( !pt->m_MasterClass.IsEmpty() )
{
@ -677,13 +678,13 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar** ppVars, CBotS
// finally execution of the found function
if ( !pStk3->GivRetVar( // puts the result on the stack
pt->m_Block->Execute(pStk3) )) // GivRetVar said if it is interrupted
if ( !pStk3->GetRetVar( // puts the result on the stack
pt->m_Block->Execute(pStk3) )) // GetRetVar said if it is interrupted
{
if ( !pStk3->IsOk() && pt->m_pProg != m_pProg )
{
#ifdef _DEBUG
if ( m_pProg->GivFunctions()->GivName() == "LaCommande" ) return false;
if ( m_pProg->GetFunctions()->GetName() == "LaCommande" ) return false;
#endif
pStk3->SetPosError(pToken); // indicates the error on the procedure call
}
@ -713,7 +714,7 @@ void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar** ppVars,
pStk1->SetBotCall(pt->m_pProg); // it may have changed module
if ( pStk1->GivBlock() < 2 )
if ( pStk1->GetBlock() < 2 )
{
CBotStack* pStk2 = pStk1->RestoreStack(NULL); // used more
if ( pStk2 == NULL ) return;
@ -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);
@ -739,7 +740,7 @@ void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar** ppVars,
}
}
if ( pStk1->GivState() == 0 )
if ( pStk1->GetState() == 0 )
{
pt->m_Param->RestoreState(pStk3, true);
return;
@ -759,13 +760,13 @@ void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar** ppVars,
int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken, CBotClass* pClass)
{
CBotTypResult type;
CBotProgram* pProgCurrent = pStack->GivBotCall();
CBotProgram* pProgCurrent = pStack->GetBotCall();
CBotFunction* pt = FindLocalOrPublic(nIdent, name, ppVars, type, false);
if ( pt != NULL )
{
// DEBUG( "CBotFunction::DoCall" + pt->GivName(), 0, pStack);
// DEBUG( "CBotFunction::DoCall" + pt->GetName(), 0, pStack);
CBotStack* pStk = pStack->AddStack(pt, 2);
// if ( pStk == EOX ) return true;
@ -775,7 +776,7 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
// preparing parameters on the stack
if ( pStk->GivState() == 0 )
if ( pStk->GetState() == 0 )
{
// sets the variable "this" on the stack
CBotVar* pthis = CBotVar::Create("this", CBotTypNullPointer);
@ -783,7 +784,7 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
pthis->SetUniqNum(-2); // special value
pStk->AddVar(pthis);
CBotClass* pClass = pThis->GivClass()->GivParent();
CBotClass* pClass = pThis->GetClass()->GetParent();
if ( pClass )
{
// sets the variable "super" on the stack
@ -797,19 +798,19 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
pStk->IncState();
}
if ( pStk->GivState() == 1 )
if ( pStk->GetState() == 1 )
{
if ( pt->m_bSynchro )
{
CBotProgram* pProgBase = pStk->GivBotCall(true);
CBotProgram* pProgBase = pStk->GetBotCall(true);
if ( !pClass->Lock(pProgBase) ) return false; // expected to power \TODO attend de pouvoir
}
pStk->IncState();
}
// finally calls the found function
if ( !pStk3->GivRetVar( // puts the result on the stack
pt->m_Block->Execute(pStk3) )) // GivRetVar said if it is interrupted
if ( !pStk3->GetRetVar( // puts the result on the stack
pt->m_Block->Execute(pStk3) )) // GetRetVar said if it is interrupted
{
if ( !pStk3->IsOk() )
{
@ -855,10 +856,10 @@ void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar* pThis, C
pt->m_Param->RestoreState(pStk3, true); // parameters
if ( pStk->GivState() > 1 && // latching is effective?
if ( pStk->GetState() > 1 && // latching is effective?
pt->m_bSynchro )
{
CBotProgram* pProgBase = pStk->GivBotCall(true);
CBotProgram* pProgBase = pStk->GetBotCall(true);
pClass->Lock(pProgBase); // locks the class
}
@ -874,21 +875,21 @@ bool CBotFunction::CheckParam(CBotDefParam* pParam)
CBotDefParam* pp = m_Param;
while ( pp != NULL && pParam != NULL )
{
CBotTypResult type1 = pp->GivType();
CBotTypResult type2 = pParam->GivType();
CBotTypResult type1 = pp->GetType();
CBotTypResult type2 = pParam->GetType();
if ( !type1.Compare(type2) ) return false;
pp = pp->GivNext();
pParam = pParam->GivNext();
pp = pp->GetNext();
pParam = pParam->GetNext();
}
return ( pp == NULL && pParam == NULL );
}
CBotString CBotFunction::GivName()
CBotString CBotFunction::GetName()
{
return m_token.GivString();
return m_token.GetString();
}
CBotString CBotFunction::GivParams()
CBotString CBotFunction::GetParams()
{
if ( m_Param == NULL ) return CBotString("()");
@ -897,8 +898,8 @@ CBotString CBotFunction::GivParams()
while (p != NULL)
{
params += p->GivParamString();
p = p->GivNext();
params += p->GetParamString();
p = p->GetNext();
if ( p != NULL ) params += ", ";
}
@ -945,7 +946,7 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
// mainly not pStack->TokenStack here
// declared variables must remain visible thereafter
pStack->SetStartError(p->GivStart());
pStack->SetStartError(p->GetStart());
if (IsOfType(p, ID_OPENPAR))
{
@ -957,12 +958,12 @@ 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);
param->m_typename = p->GivString();
// 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
if (param->m_type.GivType() > 0)
if (param->m_type.GetType() > 0)
{
CBotToken* pp = p;
param->m_token = *p;
@ -977,17 +978,17 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
}
if ( type.Eq(CBotTypArrayPointer) ) type.SetType(CBotTypArrayBody);
CBotVar* var = CBotVar::Create(pp->GivString(), type); // creates the variable
CBotVar* var = CBotVar::Create(pp->GetString(), type); // creates the variable
// if ( pClass ) var->SetClass(pClass);
var->SetInit(2); // mark initialized
param->m_nIdent = CBotVar::NextUniqNum();
var->SetUniqNum(param->m_nIdent);
pStack->AddVar(var); // place on the stack
if (IsOfType(p, ID_COMMA) || p->GivType() == ID_CLOSEPAR)
if (IsOfType(p, ID_COMMA) || p->GetType() == ID_CLOSEPAR)
continue;
}
pStack->SetError(TX_CLOSEPAR, p->GivStart());
pStack->SetError(TX_CLOSEPAR, p->GetStart());
}
pStack->SetError(TX_NOTYP, p);
delete list;
@ -995,7 +996,7 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
}
return list;
}
pStack->SetError(TX_OPENPAR, p->GivStart());
pStack->SetError(TX_OPENPAR, p->GetStart());
return NULL;
}
@ -1016,32 +1017,32 @@ bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
while ( p != NULL )
{
// creates a local variable on the stack
CBotVar* newvar = CBotVar::Create(p->m_token.GivString(), p->m_type);
CBotVar* newvar = CBotVar::Create(p->m_token.GetString(), p->m_type);
// serves to make the transformation of types:
if ( ppVars != NULL && ppVars[i] != NULL )
{
switch (p->m_type.GivType())
switch (p->m_type.GetType())
{
case CBotTypInt:
newvar->SetValInt(ppVars[i]->GivValInt());
newvar->SetValInt(ppVars[i]->GetValInt());
break;
case CBotTypFloat:
newvar->SetValFloat(ppVars[i]->GivValFloat());
newvar->SetValFloat(ppVars[i]->GetValFloat());
break;
case CBotTypString:
newvar->SetValString(ppVars[i]->GivValString());
newvar->SetValString(ppVars[i]->GetValString());
break;
case CBotTypBoolean:
newvar->SetValInt(ppVars[i]->GivValInt());
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:
{
newvar->SetPointer(ppVars[i]->GivPointer());
newvar->SetPointer(ppVars[i]->GetPointer());
}
break;
default:
@ -1059,41 +1060,41 @@ 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 )
{
// creates a local variable on the stack
CBotVar* var = pj->FindVar(p->m_token.GivString());
CBotVar* var = pj->FindVar(p->m_token.GetString());
var->SetUniqNum(p->m_nIdent);
p = p->m_next;
}
}
int CBotDefParam::GivType()
int CBotDefParam::GetType()
{
return m_type.GivType();
return m_type.GetType();
}
CBotTypResult CBotDefParam::GivTypResult()
CBotTypResult CBotDefParam::GetTypResult()
{
return m_type;
}
CBotDefParam* CBotDefParam::GivNext()
CBotDefParam* CBotDefParam::GetNext()
{
return m_next;
}
CBotString CBotDefParam::GivParamString()
CBotString CBotDefParam::GetParamString()
{
CBotString param;
param = m_typename;
param += ' ';
param += m_token.GivString();
param += m_token.GetString();
return param;
}
@ -1122,9 +1123,9 @@ CBotInstr* CBotReturn::Compile(CBotToken* &p, CBotCStack* pStack)
CBotReturn* inst = new CBotReturn(); // creates the object
inst->SetToken( pp );
CBotTypResult type = pStack->GivRetType();
CBotTypResult type = pStack->GetRetType();
if ( type.GivType() == 0 ) // returned void ?
if ( type.GetType() == 0 ) // returned void ?
{
if ( IsOfType( p, ID_SEP ) ) return inst;
pStack->SetError( TX_BADTYPE, pp );
@ -1134,15 +1135,15 @@ CBotInstr* CBotReturn::Compile(CBotToken* &p, CBotCStack* pStack)
inst->m_Instr = CBotExpression::Compile(p, pStack);
if ( pStack->IsOk() )
{
CBotTypResult retType = pStack->GivTypResult(2);
CBotTypResult retType = pStack->GetTypResult(2);
if (TypeCompatible(retType, type, ID_ASS))
{
if ( IsOfType( p, ID_SEP ) )
return inst;
pStack->SetError(TX_ENDOF, p->GivStart());
pStack->SetError(TX_ENDOF, p->GetStart());
}
pStack->SetError(TX_BADTYPE, p->GivStart());
pStack->SetError(TX_BADTYPE, p->GetStart());
}
delete inst;
@ -1154,7 +1155,7 @@ bool CBotReturn::Execute(CBotStack* &pj)
CBotStack* pile = pj->AddStack(this);
// if ( pile == EOX ) return true;
if ( pile->GivState() == 0 )
if ( pile->GetState() == 0 )
{
if ( m_Instr != NULL && !m_Instr->Execute(pile) ) return false; // evaluate the result
// the result is on the stack
@ -1173,7 +1174,7 @@ void CBotReturn::RestoreState(CBotStack* &pj, bool bMain)
CBotStack* pile = pj->RestoreStack(this);
if ( pile == NULL ) return;
if ( pile->GivState() == 0 )
if ( pile->GetState() == 0 )
{
if ( m_Instr != NULL ) m_Instr->RestoreState(pile, bMain); // evaluate the result
return;
@ -1202,9 +1203,9 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
int i = 0;
CBotToken* pp = p;
p = p->GivNext();
p = p->GetNext();
pStack->SetStartError(p->GivStart());
pStack->SetStartError(p->GetStart());
CBotCStack* pile = pStack;
if ( IsOfType(p, ID_OPENPAR) )
@ -1216,11 +1217,11 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
// compile la list of parameters
if (!IsOfType(p, ID_CLOSEPAR)) while (true)
{
start = p->GivStart();
start = p->GetStart();
pile = pile->TokenStack(); // keeps the results on the stack
CBotInstr* param = CBotExpression::Compile(p, pile);
end = p->GivStart();
end = p->GetStart();
if ( inst->m_Parameters == NULL ) inst->m_Parameters = param;
else inst->m_Parameters->AddNext(param); // constructs the list
@ -1232,22 +1233,22 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
if ( param != NULL )
{
if ( pile->GivTypResult().Eq(99) )
if ( pile->GetTypResult().Eq(99) )
{
delete pStack->TokenStack();
pStack->SetError(TX_VOID, p->GivStart());
pStack->SetError(TX_VOID, p->GetStart());
delete inst;
return NULL;
}
ppVars[i] = pile->GivVar();
ppVars[i]->GivToken()->SetPos(start, end);
ppVars[i] = pile->GetVar();
ppVars[i]->GetToken()->SetPos(start, end);
i++;
if (IsOfType(p, ID_COMMA)) continue; // skips the comma
if (IsOfType(p, ID_CLOSEPAR)) break;
}
pStack->SetError(TX_CLOSEPAR, p->GivStart());
pStack->SetError(TX_CLOSEPAR, p->GetStart());
delete pStack->TokenStack();
delete inst;
return NULL;
@ -1257,17 +1258,17 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
// the routine is known?
// CBotClass* pClass = NULL;
inst->m_typRes = pStack->CompileCall(pp, ppVars, inst->m_nFuncIdent);
if ( inst->m_typRes.GivType() >= 20 )
if ( inst->m_typRes.GetType() >= 20 )
{
// if (pVar2!=NULL) pp = pVar2->RetToken();
pStack->SetError( inst->m_typRes.GivType(), pp );
pStack->SetError( inst->m_typRes.GetType(), pp );
delete pStack->TokenStack();
delete inst;
return NULL;
}
delete pStack->TokenStack();
if ( inst->m_typRes.GivType() > 0 )
if ( inst->m_typRes.GetType() > 0 )
{
CBotVar* pRes = CBotVar::Create("", inst->m_typRes);
pStack->SetVar(pRes); // for knowing the type of the result
@ -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;
@ -1298,13 +1299,13 @@ bool CBotInstrCall::Execute(CBotStack* &pj)
if ( p != NULL) while ( true )
{
pile = pile->AddStack(); // place on the stack for the results
if ( pile->GivState() == 0 )
if ( pile->GetState() == 0 )
{
if (!p->Execute(pile)) return false; // interrupted here?
pile->SetState(1); // mark as special for reknowed parameters \TODO marque spéciale pour reconnaîre parameters
}
ppVars[i++] = pile->GivVar();
p = p->GivNext();
ppVars[i++] = pile->GetVar();
p = p->GetNext();
if ( p == NULL) break;
}
ppVars[i] = NULL;
@ -1312,7 +1313,7 @@ bool CBotInstrCall::Execute(CBotStack* &pj)
CBotStack* pile2 = pile->AddStack();
if ( pile2->IfStep() ) return false;
if ( !pile2->ExecuteCall(m_nFuncIdent, GivToken(), ppVars, m_typRes)) return false; // interrupt
if ( !pile2->ExecuteCall(m_nFuncIdent, GetToken(), ppVars, m_typRes)) return false; // interrupt
return pj->Return(pile2); // release the entire stack
}
@ -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];
@ -1336,13 +1337,13 @@ void CBotInstrCall::RestoreState(CBotStack* &pj, bool bMain)
{
pile = pile->RestoreStack(); // place on the stack for the results
if ( pile == NULL ) return;
if ( pile->GivState() == 0 )
if ( pile->GetState() == 0 )
{
p->RestoreState(pile, bMain); // interrupt here!
return;
}
ppVars[i++] = pile->GivVar(); // constructs the list of parameters
p = p->GivNext();
ppVars[i++] = pile->GetVar(); // constructs the list of parameters
p = p->GetNext();
if ( p == NULL) break;
}
ppVars[i] = NULL;
@ -1350,7 +1351,7 @@ void CBotInstrCall::RestoreState(CBotStack* &pj, bool bMain)
CBotStack* pile2 = pile->RestoreStack();
if ( pile2 == NULL ) return;
pile2->RestoreCall(m_nFuncIdent, GivToken(), ppVars);
pile2->RestoreCall(m_nFuncIdent, GetToken(), ppVars);
}
//////////////////////////////////////////////////////////////////////////////
@ -1369,7 +1370,7 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
if ( !IsOfType(p, ID_CLASS) ) return NULL;
CBotString name = p->GivString();
CBotString name = p->GetString();
CBotClass* pOld = CBotClass::Find(name);
if ( pOld != NULL && pOld->m_IsDef )
@ -1384,7 +1385,7 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
CBotClass* pPapa = NULL;
if ( IsOfType( p, ID_EXTENDS ) )
{
CBotString name = p->GivString();
CBotString name = p->GetString();
pPapa = CBotClass::Find(name);
if (!IsOfType(p, TokenTypVar) || pPapa == NULL )
@ -1454,7 +1455,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
{
CBotInstr* i = NULL;
if ( p->GivType() != ID_CLBRK )
if ( p->GetType() != ID_CLBRK )
i = CBotExpression::Compile( p, pStack ); // expression for the value
else
i = new CBotEmpty(); // special if not a formula
@ -1463,14 +1464,14 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
if (!pStack->IsOk() || !IsOfType( p, ID_CLBRK ) )
{
pStack->SetError(TX_CLBRK, p->GivStart());
pStack->SetError(TX_CLBRK, p->GetStart());
return false;
}
/* CBotVar* pv = pStack->GivVar();
if ( pv->GivType()>= CBotTypBoolean )
/* CBotVar* pv = pStack->GetVar();
if ( pv->GetType()>= CBotTypBoolean )
{
pStack->SetError(TX_BADTYPE, p->GivStart());
pStack->SetError(TX_BADTYPE, p->GetStart());
return false;
}*/
@ -1478,7 +1479,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
else limites->AddNext3(i);
}
if ( p->GivType() == ID_OPENPAR )
if ( p->GetType() == ID_OPENPAR )
{
if ( !bSecond )
{
@ -1498,12 +1499,12 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
CBotFunction* prev = NULL;
while ( pf != NULL )
{
if (pf->GivName() == pp->GivString()) break;
if (pf->GetName() == pp->GetString()) break;
prev = pf;
pf = pf->Next();
}
bool bConstructor = (pp->GivString() == GivName());
bool bConstructor = (pp->GetString() == GetName());
CBotCStack* pile = pStack->TokenStack(NULL, true);
// make "this" known
@ -1531,9 +1532,9 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
{
CBotVar* pcopy = CBotVar::Create(pv);
pcopy->SetInit(!bConstructor || pv->IsStatic());
pcopy->SetUniqNum(pv->GivUniqNum());
pcopy->SetUniqNum(pv->GetUniqNum());
pile->AddVar(pcopy);
pv = pv->GivNext();
pv = pv->GetNext();
}
my = my->m_pParent;
}
@ -1545,7 +1546,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
if ( f != NULL )
{
f->m_pProg = pStack->GivBotCall();
f->m_pProg = pStack->GetBotCall();
f->m_bSynchro = bSynchro;
// replaces the element in the chain
f->m_next = pf->m_next;
@ -1572,7 +1573,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
{
if ( type.Eq(CBotTypArrayPointer) )
{
i = CBotListArray::Compile(p, pStack, type.GivTypElem());
i = CBotListArray::Compile(p, pStack, type.GetTypElem());
}
else
{
@ -1585,7 +1586,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
if ( !bSecond )
{
CBotVar* pv = CBotVar::Create(pp->GivString(), type);
CBotVar* pv = CBotVar::Create(pp->GetString(), type);
pv -> SetStatic( bStatic );
pv -> SetPrivate( mProtect );
@ -1599,7 +1600,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
{
CBotStack* pile = CBotStack::FirstStack(); // independent stack
while(pile->IsOk() && !pv->m_InitExpr->Execute(pile)); // evaluates the expression without timer
pv->SetVal( pile->GivVar() ) ;
pv->SetVal( pile->GetVar() ) ;
pile->Delete();
}
}
@ -1620,7 +1621,7 @@ CBotClass* CBotClass::Compile(CBotToken* &p, CBotCStack* pStack)
if ( !IsOfType(p, ID_PUBLIC) ) return NULL;
if ( !IsOfType(p, ID_CLASS) ) return NULL;
CBotString name = p->GivString();
CBotString name = p->GetString();
// a name for the class is there?
if (IsOfType(p, TokenTypVar))

View File

@ -95,7 +95,7 @@ bool CBotIf :: Execute(CBotStack* &pj)
if ( pile->IfStep() ) return false;
// according to recovery, it may be in one of two states
if( pile->GivState() == 0 )
if( pile->GetState() == 0 )
{
// evaluates the condition
if ( !m_Condition->Execute(pile) ) return false; // interrupted here?
@ -113,7 +113,7 @@ bool CBotIf :: Execute(CBotStack* &pj)
// second state, evaluates the associated instructions
// the result of the condition is on the stack
if ( pile->GivVal() == true ) // condition was true?
if ( pile->GetVal() == true ) // condition was true?
{
if ( m_Block != NULL && // block may be absent
!m_Block->Execute(pile) ) return false; // interrupted here?
@ -137,7 +137,7 @@ void CBotIf :: RestoreState(CBotStack* &pj, bool bMain)
if ( pile == NULL ) return;
// according to recovery, it may be in one of two states
if( pile->GivState() == 0 )
if( pile->GetState() == 0 )
{
// evaluates the condition
m_Condition->RestoreState(pile, bMain); // interrupted here!
@ -147,7 +147,7 @@ void CBotIf :: RestoreState(CBotStack* &pj, bool bMain)
// second state, evaluates the associated instructions
// the result of the condition is on the stack
if ( pile->GivVal() == true ) // condition was true?
if ( pile->GetVal() == true ) // condition was true?
{
if ( m_Block != NULL ) // block may be absent
m_Block->RestoreState(pile, bMain); // interrupted here!

View File

@ -87,18 +87,18 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
CBotCStack* pStack = new CBotCStack(NULL);
CBotToken* p = pBaseToken->GivNext(); // skips the first token (separator)
CBotToken* p = pBaseToken->GetNext(); // skips the first token (separator)
pStack->SetBotCall(this); // defined used routines
CBotCall::SetPUser(pUser);
// first made a quick pass just to take the headers of routines and classes
while ( pStack->IsOk() && p != NULL && p->GivType() != 0)
while ( pStack->IsOk() && p != NULL && p->GetType() != 0)
{
if ( IsOfType(p, ID_SEP) ) continue; // semicolons lurking
if ( p->GivType() == ID_CLASS ||
( p->GivType() == ID_PUBLIC && p->GivNext()->GivType() == ID_CLASS ))
if ( p->GetType() == ID_CLASS ||
( p->GetType() == ID_PUBLIC && p->GetNext()->GetType() == ID_CLASS ))
{
CBotClass* nxt = CBotClass::Compile1(p, pStack);
if (m_pClass == NULL ) m_pClass = nxt;
@ -113,7 +113,7 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
}
if ( !pStack->IsOk() )
{
m_ErrorCode = pStack->GivError(m_ErrorStart, m_ErrorEnd);
m_ErrorCode = pStack->GetError(m_ErrorStart, m_ErrorEnd);
delete m_Prog;
m_Prog = NULL;
delete pBaseToken;
@ -123,14 +123,14 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
// CBotFunction* temp = NULL;
CBotFunction* next = m_Prog; // rewind the list
p = pBaseToken->GivNext(); // returns to the beginning
p = pBaseToken->GetNext(); // returns to the beginning
while ( pStack->IsOk() && p != NULL && p->GivType() != 0 )
while ( pStack->IsOk() && p != NULL && p->GetType() != 0 )
{
if ( IsOfType(p, ID_SEP) ) continue; // semicolons lurking
if ( p->GivType() == ID_CLASS ||
( p->GivType() == ID_PUBLIC && p->GivNext()->GivType() == ID_CLASS ))
if ( p->GetType() == ID_CLASS ||
( p->GetType() == ID_PUBLIC && p->GetNext()->GetType() == ID_CLASS ))
{
m_bCompileClass = true;
CBotClass::Compile(p, pStack); // completes the definition of the class
@ -139,7 +139,7 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
{
m_bCompileClass = false;
CBotFunction::Compile(p, pStack, next);
if (next->IsExtern()) ListFonctions.Add(next->GivName()/* + next->GivParams()*/);
if (next->IsExtern()) ListFonctions.Add(next->GetName()/* + next->GetParams()*/);
next->m_pProg = this; // keeps pointers to the module
next = next->Next();
}
@ -150,7 +150,7 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
if ( !pStack->IsOk() )
{
m_ErrorCode = pStack->GivError(m_ErrorStart, m_ErrorEnd);
m_ErrorCode = pStack->GetError(m_ErrorStart, m_ErrorEnd);
delete m_Prog;
m_Prog = NULL;
}
@ -174,7 +174,7 @@ bool CBotProgram::Start(const char* name)
m_pRun = m_Prog;
while (m_pRun != NULL)
{
if ( m_pRun->GivName() == name ) break;
if ( m_pRun->GetName() == name ) break;
m_pRun = m_pRun->m_next;
}
@ -200,7 +200,7 @@ bool CBotProgram::GetPosition(const char* name, int& start, int& stop, CBotGet m
CBotFunction* p = m_Prog;
while (p != NULL)
{
if ( p->GivName() == name ) break;
if ( p->GetName() == name ) break;
p = p->m_next;
}
@ -248,7 +248,7 @@ bool CBotProgram::Run(void* pUser, int timer)
// completed on a mistake?
if (!ok && !m_pStack->IsOk())
{
m_ErrorCode = m_pStack->GivError(m_ErrorStart, m_ErrorEnd);
m_ErrorCode = m_pStack->GetError(m_ErrorStart, m_ErrorEnd);
#if STACKMEM
m_pStack->Delete();
#else
@ -289,12 +289,12 @@ bool CBotProgram::GetRunPos(const char* &FunctionName, int &start, int &end)
return true;
}
CBotVar* CBotProgram::GivStackVars(const char* &FunctionName, int level)
CBotVar* CBotProgram::GetStackVars(const char* &FunctionName, int level)
{
FunctionName = NULL;
if (m_pStack == NULL) return NULL;
return m_pStack->GivStackVars(FunctionName, level);
return m_pStack->GetStackVars(FunctionName, level);
}
void CBotProgram::SetTimer(int n)
@ -302,7 +302,7 @@ void CBotProgram::SetTimer(int n)
CBotStack::SetTimer( n );
}
int CBotProgram::GivError()
int CBotProgram::GetError()
{
return m_ErrorCode;
}
@ -312,7 +312,7 @@ void CBotProgram::SetIdent(long n)
m_Ident = n;
}
long CBotProgram::GivIdent()
long CBotProgram::GetIdent()
{
return m_Ident;
}
@ -334,7 +334,7 @@ bool CBotProgram::GetError(int& code, int& start, int& end, CBotProgram* &pProg)
return code > 0;
}
CBotString CBotProgram::GivErrorText(int code)
CBotString CBotProgram::GetErrorText(int code)
{
CBotString TextError;
@ -349,7 +349,7 @@ CBotString CBotProgram::GivErrorText(int code)
}
CBotFunction* CBotProgram::GivFunctions()
CBotFunction* CBotProgram::GetFunctions()
{
return m_Prog;
}
@ -421,7 +421,7 @@ bool WriteString(FILE* pf, CBotString s)
{
size_t lg1, lg2;
lg1 = s.GivLength();
lg1 = s.GetLength();
if (!WriteWord(pf, lg1)) return false;
lg2 = fwrite(s, 1, lg1, pf );
@ -445,19 +445,19 @@ bool ReadString(FILE* pf, CBotString& s)
bool WriteType(FILE* pf, CBotTypResult type)
{
int typ = type.GivType();
int typ = type.GetType();
if ( typ == CBotTypIntrinsic ) typ = CBotTypClass;
if ( !WriteWord(pf, typ) ) return false;
if ( typ == CBotTypClass )
{
CBotClass* p = type.GivClass();
if ( !WriteString(pf, p->GivName()) ) return false;
CBotClass* p = type.GetClass();
if ( !WriteString(pf, p->GetName()) ) return false;
}
if ( type.Eq( CBotTypArrayBody ) ||
type.Eq( CBotTypArrayPointer ) )
{
if ( !WriteWord(pf, type.GivLimite()) ) return false;
if ( !WriteType(pf, type.GivTypElem()) ) return false;
if ( !WriteWord(pf, type.GetLimite()) ) return false;
if ( !WriteType(pf, type.GetTypElem()) ) return false;
}
return true;
}
@ -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;
}
@ -507,7 +507,7 @@ bool CBotProgram::SaveState(FILE* pf)
if ( m_pStack != NULL )
{
if (!WriteWord( pf, 1)) return false;
if (!WriteString( pf, m_pRun->GivName() )) return false;
if (!WriteString( pf, m_pRun->GetName() )) return false;
if (!m_pStack->SaveState(pf)) return false;
}
else
@ -551,7 +551,7 @@ bool CBotProgram::RestoreState(FILE* pf)
return true;
}
int CBotProgram::GivVersion()
int CBotProgram::GetVersion()
{
return CBOTVERSION;
}
@ -592,7 +592,7 @@ bool CBotCall::AddFunction(const char* name,
if ( p != NULL ) while ( p->m_next != NULL )
{
if ( p->GivName() == name )
if ( p->GetName() == name )
{
// frees redefined function
if ( pp ) pp->m_next = p->m_next;
@ -625,14 +625,14 @@ CBotVar* MakeListVars(CBotVar** ppVars, bool bSetVal=false)
while( true )
{
ppVars[i];
// ppVars[i];
if ( ppVars[i] == NULL ) break;
CBotVar* pp = CBotVar::Create(ppVars[i]);
if (bSetVal) pp->Copy(ppVars[i]);
else
if ( ppVars[i]->GivType() == CBotTypPointer )
pp->SetClass( ppVars[i]->GivClass());
if ( ppVars[i]->GetType() == CBotTypPointer )
pp->SetClass( ppVars[i]->GetClass());
// copy the pointer according to indirections
if (pVar == NULL) pVar = pp;
else pVar->AddNext(pp);
@ -648,7 +648,7 @@ CBotTypResult CBotCall::CompileCall(CBotToken* &p, CBotVar** ppVar, CBotCStack*
{
nIdent = 0;
CBotCall* pt = m_ListCalls;
CBotString name = p->GivString();
CBotString name = p->GetString();
while ( pt != NULL )
{
@ -657,14 +657,14 @@ CBotTypResult CBotCall::CompileCall(CBotToken* &p, CBotVar** ppVar, CBotCStack*
CBotVar* pVar = MakeListVars(ppVar);
CBotVar* pVar2 = pVar;
CBotTypResult r = pt->m_rComp(pVar2, m_pUser);
int ret = r.GivType();
int ret = r.GetType();
// if a class is returned, it is actually a pointer
if ( ret == CBotTypClass ) r.SetType( ret = CBotTypPointer );
if ( ret > 20 )
{
if (pVar2) pStack->SetError(ret, p /*pVar2->GivToken()*/ );
if (pVar2) pStack->SetError(ret, p /*pVar2->GetToken()*/ );
}
delete pVar;
nIdent = pt->m_nFuncIdent;
@ -688,7 +688,7 @@ bool CBotCall::CheckCall(const char* name)
while ( p != NULL )
{
if ( name == p->GivName() ) return true;
if ( name == p->GetName() ) return true;
p = p->m_next;
}
return false;
@ -696,7 +696,7 @@ bool CBotCall::CheckCall(const char* name)
CBotString CBotCall::GivName()
CBotString CBotCall::GetName()
{
return m_name;
}
@ -724,7 +724,7 @@ int CBotCall::DoCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotStack*
if ( token != NULL )
{
CBotString name = token->GivString();
CBotString name = token->GetString();
while ( pt != NULL )
{
if ( pt->m_name == name )
@ -750,7 +750,7 @@ fund:
CBotVar* pRes = pResult;
int Exception = 0;
int res = pt->m_rExec(pVar, pResult, Exception, pStack->GivPUser());
int res = pt->m_rExec(pVar, pResult, Exception, pStack->GetPUser());
if ( pResult != pRes ) delete pRes; // different result if made
delete pVarToDelete;
@ -766,7 +766,7 @@ fund:
}
pStack->SetVar(pResult);
if ( rettype.GivType() > 0 && pResult == NULL )
if ( rettype.GetType() > 0 && pResult == NULL )
{
pStack->SetError(TX_NORETVAL, token);
}
@ -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);
@ -805,7 +805,7 @@ bool CBotCall::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBot
CBotCall* pt = m_ListCalls;
{
CBotString name = token->GivString();
CBotString name = token->GetString();
while ( pt != NULL )
{
if ( pt->m_name == name )
@ -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;
@ -829,14 +830,14 @@ bool CBotCall::Run(CBotStack* pStack)
{
CBotStack* pile = pStack->AddStackEOX(this);
if ( pile == EOX ) return true;
CBotVar* pVar = pile->GivVar();
CBotVar* pVar = pile->GetVar();
CBotStack* pile2 = pile->AddStack();
CBotVar* pResult = pile2->GivVar();
CBotVar* pResult = pile2->GetVar();
CBotVar* pRes = pResult;
int Exception = 0;
int res = m_rExec(pVar, pResult, Exception, pStack->GivPUser());
int res = m_rExec(pVar, pResult, Exception, pStack->GetPUser());
if (res == false)
{
@ -892,10 +893,10 @@ CBotTypResult CBotCallMethode::CompileCall(const char* name, CBotVar* pThis,
CBotVar* pVar = MakeListVars(ppVar, true);
CBotVar* pVar2 = pVar;
CBotTypResult r = pt->m_rComp(pThis, pVar2);
int ret = r.GivType();
int ret = r.GetType();
if ( ret > 20 )
{
if (pVar2) pStack->SetError(ret, pVar2->GivToken());
if (pVar2) pStack->SetError(ret, pVar2->GetToken());
}
delete pVar;
nIdent = pt->m_nFuncIdent;
@ -907,7 +908,7 @@ CBotTypResult CBotCallMethode::CompileCall(const char* name, CBotVar* pThis,
}
CBotString CBotCallMethode::GivName()
CBotString CBotCallMethode::GetName()
{
return m_name;
}
@ -951,7 +952,7 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
{
if (Exception!=0)
{
// pStack->SetError(Exception, pVar->GivToken());
// pStack->SetError(Exception, pVar->GetToken());
pStack->SetError(Exception, pToken);
}
delete pVarToDelete;
@ -982,7 +983,7 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
{
if (Exception!=0)
{
// pStack->SetError(Exception, pVar->GivToken());
// pStack->SetError(Exception, pVar->GetToken());
pStack->SetError(Exception, pToken);
}
delete pVarToDelete;
@ -1003,12 +1004,12 @@ bool rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
if ( pVar == NULL ) return TX_LOWPARAM;
int i = 0;
pVar = pVar->GivItemList();
pVar = pVar->GetItemList();
while ( pVar != NULL )
{
i++;
pVar = pVar->GivNext();
pVar = pVar->GetNext();
}
pResult->SetValInt(i);
@ -1018,7 +1019,7 @@ bool rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
CBotTypResult cSizeOf( CBotVar* &pVar, void* pUser )
{
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
if ( pVar->GivType() != CBotTypArrayPointer )
if ( pVar->GetType() != CBotTypArrayPointer )
return CBotTypResult( TX_BADPARAM );
return CBotTypResult( CBotTypInt );
}

View File

@ -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);
@ -198,7 +198,7 @@ CBotStack* CBotStack::AddStack2(bool bBlock)
return p;
}
bool CBotStack::GivBlock()
bool CBotStack::GetBlock()
{
return m_bBlock;
}
@ -428,7 +428,7 @@ void CBotStack::SetBreak(int val, const char* name)
// gives on the stack value calculated by the last CBotReturn
bool CBotStack::GivRetVar(bool bRet)
bool CBotStack::GetRetVar(bool bRet)
{
if (m_error == -3)
{
@ -441,7 +441,7 @@ bool CBotStack::GivRetVar(bool bRet)
return bRet; // interrupted by something other than return
}
int CBotStack::GivError(int& start, int& end)
int CBotStack::GetError(int& start, int& end)
{
start = m_start;
end = m_end;
@ -449,16 +449,16 @@ int CBotStack::GivError(int& start, int& end)
}
int CBotStack::GivType(int mode)
int CBotStack::GetType(int mode)
{
if (m_var == NULL) return -1;
return m_var->GivType(mode);
return m_var->GetType(mode);
}
CBotTypResult CBotStack::GivTypResult(int mode)
CBotTypResult CBotStack::GetTypResult(int mode)
{
if (m_var == NULL) return -1;
return m_var->GivTypResult(mode);
return m_var->GetTypResult(mode);
}
void CBotStack::SetType(CBotTypResult& type)
@ -471,14 +471,14 @@ void CBotStack::SetType(CBotTypResult& type)
CBotVar* CBotStack::FindVar(CBotToken* &pToken, bool bUpdate, bool bModif)
{
CBotStack* p = this;
CBotString name = pToken->GivString();
CBotString name = pToken->GetString();
while (p != NULL)
{
CBotVar* pp = p->m_listVar;
while ( pp != NULL)
{
if (pp->GivName() == name)
if (pp->GetName() == name)
{
if ( bUpdate )
pp->Maj(m_pUser, false);
@ -500,7 +500,7 @@ CBotVar* CBotStack::FindVar(const char* name)
CBotVar* pp = p->m_listVar;
while ( pp != NULL)
{
if (pp->GivName() == name)
if (pp->GetName() == name)
{
return pp;
}
@ -519,7 +519,7 @@ CBotVar* CBotStack::FindVar(long ident, bool bUpdate, bool bModif)
CBotVar* pp = p->m_listVar;
while ( pp != NULL)
{
if (pp->GivUniqNum() == ident)
if (pp->GetUniqNum() == ident)
{
if ( bUpdate )
pp->Maj(m_pUser, false);
@ -576,8 +576,8 @@ void CBotStack::SetError(int n, CBotToken* token)
m_error = n;
if (token != NULL)
{
m_start = token->GivStart();
m_end = token->GivEnd();
m_start = token->GetStart();
m_end = token->GetEnd();
}
}
@ -590,8 +590,8 @@ void CBotStack::ResetError(int n, int start, int end)
void CBotStack::SetPosError(CBotToken* token)
{
m_start = token->GivStart();
m_end = token->GivEnd();
m_start = token->GetStart();
m_end = token->GetEnd();
}
void CBotStack::SetTimer(int n)
@ -643,34 +643,34 @@ void CBotStack::SetCopyVar( CBotVar* var )
{
if (m_var) delete m_var; // replacement of a variable
m_var = CBotVar::Create("", var->GivTypResult(2));
m_var = CBotVar::Create("", var->GetTypResult(2));
m_var->Copy( var );
}
CBotVar* CBotStack::GivVar()
CBotVar* CBotStack::GetVar()
{
return m_var;
}
CBotVar* CBotStack::GivPtVar()
CBotVar* CBotStack::GetPtVar()
{
CBotVar* p = m_var;
m_var = NULL; // therefore will not be destroyed
return p;
}
CBotVar* CBotStack::GivCopyVar()
CBotVar* CBotStack::GetCopyVar()
{
if (m_var == NULL) return NULL;
CBotVar* v = CBotVar::Create("", m_var->GivType());
CBotVar* v = CBotVar::Create("", m_var->GetType());
v->Copy( m_var );
return v;
}
long CBotStack::GivVal()
long CBotStack::GetVal()
{
if (m_var == NULL) return 0;
return m_var->GivValInt();
return m_var->GetValInt();
}
@ -693,7 +693,7 @@ void CBotStack::AddVar(CBotVar* pVar)
*pp = pVar; // added after
#ifdef _DEBUG
if ( pVar->GivUniqNum() == 0 ) ASM_TRAP();
if ( pVar->GetUniqNum() == 0 ) ASM_TRAP();
#endif
}
@ -710,7 +710,7 @@ void CBotStack::SetBotCall(CBotProgram* p)
m_bFunc = true;
}
CBotProgram* CBotStack::GivBotCall(bool bFirst)
CBotProgram* CBotStack::GetBotCall(bool bFirst)
{
if ( ! bFirst ) return m_prog;
CBotStack* p = this;
@ -718,7 +718,7 @@ CBotProgram* CBotStack::GivBotCall(bool bFirst)
return p->m_prog;
}
void* CBotStack::GivPUser()
void* CBotStack::GetPUser()
{
return m_pUser;
}
@ -731,19 +731,19 @@ bool CBotStack::ExecuteCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBo
// first looks by the identifier
res = CBotCall::DoCall(nIdent, NULL, ppVar, this, rettype );
if (res.GivType() >= 0) return res.GivType();
if (res.GetType() >= 0) return res.GetType();
res = m_prog->GivFunctions()->DoCall(nIdent, NULL, ppVar, this, token );
if (res.GivType() >= 0) return res.GivType();
res = m_prog->GetFunctions()->DoCall(nIdent, NULL, ppVar, this, token );
if (res.GetType() >= 0) return res.GetType();
// if not found (recompile?) seeks by name
nIdent = 0;
res = CBotCall::DoCall(nIdent, token, ppVar, this, rettype );
if (res.GivType() >= 0) return res.GivType();
if (res.GetType() >= 0) return res.GetType();
res = m_prog->GivFunctions()->DoCall(nIdent, token->GivString(), ppVar, this, token );
if (res.GivType() >= 0) return res.GivType();
res = m_prog->GetFunctions()->DoCall(nIdent, token->GetString(), ppVar, this, token );
if (res.GetType() >= 0) return res.GetType();
SetError(TX_NOCALL, token);
return true;
@ -754,7 +754,7 @@ void CBotStack::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar)
if ( m_next == NULL ) return;
if ( !CBotCall::RestoreCall(nIdent, token, ppVar, this) )
m_prog->GivFunctions()->RestoreCall(nIdent, token->GivString(), ppVar, this );
m_prog->GetFunctions()->RestoreCall(nIdent, token->GetString(), ppVar, this );
}
@ -770,7 +770,7 @@ bool SaveVar(FILE* pf, CBotVar* pVar)
if ( !pVar->Save0State(pf)) return false; // common header
if ( !pVar->Save1State(pf) ) return false; // saves as the child class
pVar = pVar->GivNext();
pVar = pVar->GetNext();
}
}
@ -798,17 +798,17 @@ void CBotStack::GetRunPos(const char* &FunctionName, int &start, int &end)
if ( funct == NULL ) return;
CBotToken* t = funct->GivToken();
FunctionName = t->GivString();
CBotToken* t = funct->GetToken();
FunctionName = t->GetString();
// if ( p->m_instr != NULL ) instr = p->m_instr;
t = instr->GivToken();
start = t->GivStart();
end = t->GivEnd();
t = instr->GetToken();
start = t->GetStart();
end = t->GetEnd();
}
CBotVar* CBotStack::GivStackVars(const char* &FunctionName, int level)
CBotVar* CBotStack::GetStackVars(const char* &FunctionName, int level)
{
CBotProgram* prog = m_prog; // current program
FunctionName = NULL;
@ -846,8 +846,8 @@ CBotVar* CBotStack::GivStackVars(const char* &FunctionName, int level)
if ( pp == NULL || pp->m_instr == NULL ) return NULL;
CBotToken* t = pp->m_instr->GivToken();
FunctionName = t->GivString();
CBotToken* t = pp->m_instr->GetToken();
FunctionName = t->GetString();
return p->m_listVar;
}
@ -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
@ -924,9 +924,9 @@ bool CBotVar::Save0State(FILE* pf)
{
if (!WriteWord(pf, 100+m_mPrivate))return false; // private variable?
if (!WriteWord(pf, m_bStatic))return false; // static variable?
if (!WriteWord(pf, m_type.GivType()))return false; // saves the type (always non-zero)
if (!WriteWord(pf, m_type.GetType()))return false; // saves the type (always non-zero)
if (!WriteWord(pf, m_binit))return false; // variable defined?
return WriteString(pf, m_token->GivString()); // and variable name
return WriteString(pf, m_token->GetString()); // and variable name
}
bool CBotVarInt::Save0State(FILE* pf)
@ -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:
@ -1160,7 +1160,7 @@ CBotCStack* CBotCStack::TokenStack(CBotToken* pToken, bool bBlock)
m_next = p; // channel element
p->m_bBlock = bBlock;
if (pToken != NULL) p->SetStartError(pToken->GivStart());
if (pToken != NULL) p->SetStartError(pToken->GetStart());
return p;
}
@ -1200,42 +1200,42 @@ CBotFunction* CBotCStack::ReturnFunc(CBotFunction* inst, CBotCStack* pfils)
return inst;
}
int CBotCStack::GivError(int& start, int& end)
int CBotCStack::GetError(int& start, int& end)
{
start = m_start;
end = m_end;
return m_error;
}
int CBotCStack::GivError()
int CBotCStack::GetError()
{
return m_error;
}
// type of instruction on the stack
CBotTypResult CBotCStack::GivTypResult(int mode)
CBotTypResult CBotCStack::GetTypResult(int mode)
{
if (m_var == NULL)
return CBotTypResult(99);
return m_var->GivTypResult(mode);
return m_var->GetTypResult(mode);
}
// type of instruction on the stack
int CBotCStack::GivType(int mode)
int CBotCStack::GetType(int mode)
{
if (m_var == NULL)
return 99;
return m_var->GivType(mode);
return m_var->GetType(mode);
}
// pointer on the stack is in what class?
CBotClass* CBotCStack::GivClass()
CBotClass* CBotCStack::GetClass()
{
if ( m_var == NULL )
return NULL;
if ( m_var->GivType(1) != CBotTypPointer ) return NULL;
if ( m_var->GetType(1) != CBotTypPointer ) return NULL;
return m_var->GivClass();
return m_var->GetClass();
}
// type of instruction on the stack
@ -1252,14 +1252,14 @@ void CBotCStack::SetType(CBotTypResult& type)
CBotVar* CBotCStack::FindVar(CBotToken* &pToken)
{
CBotCStack* p = this;
CBotString name = pToken->GivString();
CBotString name = pToken->GetString();
while (p != NULL)
{
CBotVar* pp = p->m_listVar;
while ( pp != NULL)
{
if (name == pp->GivName())
if (name == pp->GetName())
{
return pp;
}
@ -1282,7 +1282,7 @@ CBotVar* CBotCStack::CopyVar(CBotToken& Token)
if ( pVar == NULL) return NULL;
CBotVar* pCopy = CBotVar::Create( "", pVar->GivType() );
CBotVar* pCopy = CBotVar::Create( "", pVar->GetType() );
pCopy->Copy(pVar);
return pCopy;
}
@ -1310,8 +1310,8 @@ void CBotCStack::SetError(int n, CBotToken* p)
{
if (m_error) return; // does not change existing error
m_error = n;
m_start = p->GivStart();
m_end = p->GivEnd();
m_start = p->GetStart();
m_end = p->GetEnd();
}
void CBotCStack::ResetError(int n, int start, int end)
@ -1325,10 +1325,10 @@ bool CBotCStack::NextToken(CBotToken* &p)
{
CBotToken* pp = p;
p = p->GivNext();
p = p->GetNext();
if (p!=NULL) return true;
SetError(TX_ENDOF, pp->GivEnd());
SetError(TX_ENDOF, pp->GetEnd());
return false;
}
@ -1337,7 +1337,7 @@ void CBotCStack::SetBotCall(CBotProgram* p)
m_prog = p;
}
CBotProgram* CBotCStack::GivBotCall()
CBotProgram* CBotCStack::GetBotCall()
{
return m_prog;
}
@ -1347,7 +1347,7 @@ void CBotCStack::SetRetType(CBotTypResult& type)
m_retTyp = type;
}
CBotTypResult CBotCStack::GivRetType()
CBotTypResult CBotCStack::GetRetType()
{
return m_retTyp;
}
@ -1364,11 +1364,11 @@ void CBotCStack::SetCopyVar( CBotVar* var )
if (m_var) delete m_var; // replacement of a variable
if ( var == NULL ) return;
m_var = CBotVar::Create("", var->GivTypResult(2));
m_var = CBotVar::Create("", var->GetTypResult(2));
m_var->Copy( var );
}
CBotVar* CBotCStack::GivVar()
CBotVar* CBotCStack::GetVar()
{
return m_var;
}
@ -1388,7 +1388,7 @@ void CBotCStack::AddVar(CBotVar* pVar)
*pp = pVar; // added after
#ifdef _DEBUG
if ( pVar->GivUniqNum() == 0 ) ASM_TRAP();
if ( pVar->GetUniqNum() == 0 ) ASM_TRAP();
#endif
}
@ -1397,14 +1397,14 @@ void CBotCStack::AddVar(CBotVar* pVar)
bool CBotCStack::CheckVarLocal(CBotToken* &pToken)
{
CBotCStack* p = this;
CBotString name = pToken->GivString();
CBotString name = pToken->GetString();
while (p != NULL)
{
CBotVar* pp = p->m_listVar;
while ( pp != NULL)
{
if (name == pp->GivName())
if (name == pp->GetName())
return true;
pp = pp->m_next;
}
@ -1420,14 +1420,14 @@ CBotTypResult CBotCStack::CompileCall(CBotToken* &p, CBotVar** ppVars, long& nId
CBotTypResult val(-1);
val = CBotCall::CompileCall(p, ppVars, this, nIdent);
if (val.GivType() < 0)
if (val.GetType() < 0)
{
val = m_prog->GivFunctions()->CompileCall(p->GivString(), ppVars, nIdent);
if ( val.GivType() < 0 )
val = m_prog->GetFunctions()->CompileCall(p->GetString(), ppVars, nIdent);
if ( val.GetType() < 0 )
{
// pVar = NULL; // the error is not on a particular parameter
SetError( -val.GivType(), p );
val.SetType(-val.GivType());
SetError( -val.GetType(), p );
val.SetType(-val.GetType());
return val;
}
}
@ -1438,14 +1438,14 @@ CBotTypResult CBotCStack::CompileCall(CBotToken* &p, CBotVar** ppVars, long& nId
bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
{
CBotString name = pToken->GivString();
CBotString name = pToken->GetString();
if ( CBotCall::CheckCall(name) ) return true;
CBotFunction* pp = m_prog->GivFunctions();
CBotFunction* pp = m_prog->GetFunctions();
while ( pp != NULL )
{
if ( pToken->GivString() == pp->GivName() )
if ( pToken->GetString() == pp->GetName() )
{
// are parameters exactly the same?
if ( pp->CheckParam( pParam ) )
@ -1457,7 +1457,7 @@ bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
pp = CBotFunction::m_listPublic;
while ( pp != NULL )
{
if ( pToken->GivString() == pp->GivName() )
if ( pToken->GetString() == pp->GetName() )
{
// are parameters exactly the same?
if ( pp->CheckParam( pParam ) )

View File

@ -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"},
@ -70,7 +70,7 @@ const std::map<EID, char *> CBotString::s_keywordString =
{ID_CLOSEPAR, ")"},
{ID_OPBLK, "{"},
{ID_CLBLK, "}"},
{ID_SEP, "},"},
{ID_SEP, ";"},
{ID_COMMA, ","},
{ID_DOTS, ":"},
{ID_DOT, "."},
@ -138,7 +138,7 @@ CBotString::CBotString(const char* p)
m_ptr = NULL;
if (m_lg>0)
{
m_ptr = (char*)malloc(m_lg+1);
m_ptr = static_cast<char*>(malloc(m_lg+1));
strcpy(m_ptr, p);
}
}
@ -150,7 +150,7 @@ CBotString::CBotString(const CBotString& srcString)
m_ptr = NULL;
if (m_lg>0)
{
m_ptr = (char*)malloc(m_lg+1);
m_ptr = static_cast<char*>(malloc(m_lg+1));
strcpy(m_ptr, srcString.m_ptr);
}
}
@ -158,7 +158,7 @@ CBotString::CBotString(const CBotString& srcString)
int CBotString::GivLength()
int CBotString::GetLength()
{
if (m_ptr == NULL) return 0;
return strlen( m_ptr );
@ -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;
}
@ -285,7 +285,7 @@ CBotString CBotString::Mid(int start, int lg)
if ( lg < 0 ) lg = m_lg - start;
char* p = (char*)malloc(m_lg+1);
char* p = static_cast<char*>(malloc(m_lg+1));
strcpy(p, m_ptr+start);
p[lg] = 0;
@ -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,14 +315,14 @@ 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);
m_ptr = NULL;
if (m_lg > 0)
{
m_ptr = (char*)malloc(m_lg+1);
m_ptr = static_cast<char*>(malloc(m_lg+1));
strcpy(m_ptr, str);
return true;
}
@ -339,7 +339,7 @@ const CBotString& CBotString::operator=(const CBotString& stringSrc)
if (m_lg > 0)
{
m_ptr = (char*)malloc(m_lg+1);
m_ptr = static_cast<char*>(malloc(m_lg+1));
strcpy(m_ptr, stringSrc.m_ptr);
}
@ -355,7 +355,7 @@ CBotString operator+(const CBotString& string, const char * lpsz)
const CBotString& CBotString::operator+(const CBotString& stringSrc)
{
char* p = (char*)malloc(m_lg+stringSrc.m_lg+1);
char* p = static_cast<char*>(malloc(m_lg+stringSrc.m_lg+1));
strcpy(p, m_ptr);
char* pp = p + m_lg;
@ -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;
@ -392,7 +392,7 @@ const CBotString& CBotString::operator=(const char* pString)
if (m_lg != 0)
{
m_ptr = (char*)malloc(m_lg+1);
m_ptr = static_cast<char*>(malloc(m_lg+1));
strcpy(m_ptr, pString);
}
}
@ -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;
@ -549,7 +549,7 @@ CBotStringArray::~CBotStringArray()
}
int CBotStringArray::GivSize()
int CBotStringArray::GetSize()
{
return m_nSize;
}
@ -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;

View File

@ -123,25 +123,25 @@ const CBotToken& CBotToken::operator=(const CBotToken& src)
}
int CBotToken::GivType()
int CBotToken::GetType()
{
if (this == NULL) return 0;
if (m_type == TokenTypKeyWord) return m_IdKeyWord;
return m_type;
}
long CBotToken::GivIdKey()
long CBotToken::GetIdKey()
{
return m_IdKeyWord;
}
CBotToken* CBotToken::GivNext()
CBotToken* CBotToken::GetNext()
{
if (this == NULL) return NULL;
return m_next;
}
CBotToken* CBotToken::GivPrev()
CBotToken* CBotToken::GetPrev()
{
if (this == NULL) return NULL;
return m_prev;
@ -159,12 +159,12 @@ void CBotToken::AddNext(CBotToken* p)
}
CBotString& CBotToken::GivString()
CBotString& CBotToken::GetString()
{
return m_Text;
}
CBotString& CBotToken::GivSep()
CBotString& CBotToken::GetSep()
{
return m_Sep;
}
@ -175,13 +175,13 @@ void CBotToken::SetString(const char* name)
}
int CBotToken::GivStart()
int CBotToken::GetStart()
{
if (this == NULL) return -1;
return m_start;
}
int CBotToken::GivEnd()
int CBotToken::GetEnd()
{
if (this == NULL) return -1;
return m_end;
@ -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
@ -309,7 +309,7 @@ cc: mot += c;
if (CharInList(mot[0], sep3)) // an operational separator?
{
CBotString motc = mot;
while (motc += c, c != 0 && GivKeyWords(motc)>0) // operand seeks the longest possible
while (motc += c, c != 0 && GetKeyWords(motc)>0) // operand seeks the longest possible
{
mot += c; // build the word
c = *(program++); // next character
@ -367,9 +367,9 @@ bis:
if (mot[0] == '\"') token->m_type = TokenTypString;
if (first) token->m_type = 0;
token->m_IdKeyWord = GivKeyWords(mot);
token->m_IdKeyWord = GetKeyWords(mot);
if (token->m_IdKeyWord > 0) token->m_type = TokenTypKeyWord;
else GivKeyDefNum(mot, token) ; // treats DefineNum
else GetKeyDefNum(mot, token) ; // treats DefineNum
return token;
}
@ -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;
@ -391,9 +391,9 @@ CBotToken* CBotToken::CompileTokens(const char* program, int& error)
if (tokenbase == NULL) return NULL;
tokenbase->m_start = pos;
pos += tokenbase->m_Text.GivLength();
pos += tokenbase->m_Text.GetLength();
tokenbase->m_end = pos;
pos += tokenbase->m_Sep.GivLength();
pos += tokenbase->m_Sep.GetLength();
char* pp = p;
while (NULL != (nxt = NextToken(p, error)))
@ -403,11 +403,11 @@ CBotToken* CBotToken::CompileTokens(const char* program, int& error)
prv = nxt; // advance
nxt->m_start = pos;
/* pos += nxt->m_Text.GivLength(); // chain may be shorter (BOA deleted)
/* pos += nxt->m_Text.GetLength(); // chain may be shorter (BOA deleted)
nxt->m_end = pos;
pos += nxt->m_Sep.GivLength();*/
pos += nxt->m_Sep.GetLength();*/
pos += (p - pp); // total size
nxt->m_end = pos - nxt->m_Sep.GivLength();
nxt->m_end = pos - nxt->m_Sep.GetLength();
pp = p;
}
@ -429,15 +429,15 @@ void CBotToken::Delete(CBotToken* pToken)
// search if a word is part of the keywords
int CBotToken::GivKeyWords(const char* w)
int CBotToken::GetKeyWords(const char* w)
{
int i;
int l = m_ListKeyWords.GivSize();
int l = m_ListKeyWords.GetSize();
if (l == 0)
{
LoadKeyWords(); // takes the list for the first time
l = m_ListKeyWords.GivSize();
l = m_ListKeyWords.GetSize();
}
for (i = 0; i < l; i++)
@ -448,10 +448,10 @@ int CBotToken::GivKeyWords(const char* w)
return -1;
}
bool CBotToken::GivKeyDefNum(const char* w, CBotToken* &token)
bool CBotToken::GetKeyDefNum(const char* w, CBotToken* &token)
{
int i;
int l = m_ListKeyDefine.GivSize();
int l = m_ListKeyDefine.GetSize();
for (i = 0; i < l; i++)
{
@ -510,7 +510,7 @@ void CBotToken::LoadKeyWords()
bool CBotToken::DefineNum(const char* name, long val)
{
int i;
int l = m_ListKeyDefine.GivSize();
int l = m_ListKeyDefine.GetSize();
for (i = 0; i < l; i++)
{
@ -525,10 +525,10 @@ bool CBotToken::DefineNum(const char* name, long val)
bool IsOfType(CBotToken* &p, int type1, int type2)
{
if (p->GivType() == type1 ||
p->GivType() == type2 )
if (p->GetType() == type1 ||
p->GetType() == type2 )
{
p = p->GivNext();
p = p->GetNext();
return true;
}
return false;
@ -539,7 +539,7 @@ bool IsOfTypeList(CBotToken* &p, int type1, ...)
{
int i = type1;
int max = 20;
int type = p->GivType();
int type = p->GetType();
va_list marker;
va_start( marker, type1 ); /* Initialize variable arguments. */
@ -548,7 +548,7 @@ bool IsOfTypeList(CBotToken* &p, int type1, ...)
{
if (type == i)
{
p = p->GivNext();
p = p->GetNext();
va_end( marker ); /* Reset variable arguments. */
return true;
}

View File

@ -136,11 +136,11 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera
if (left == NULL) return pStack->Return(NULL, pStk); // if error, transmit
// did we expected the operand?
int TypeOp = p->GivType();
int TypeOp = p->GetType();
if ( IsInList( TypeOp, pOperations, typemasque ) )
{
CBotTypResult type1, type2;
type1 = pStk->GivTypResult(); // what kind of the first operand?
type1 = pStk->GetTypResult(); // what kind of the first operand?
if ( TypeOp == ID_LOGIC ) // special case provided for: ? op1: op2;
{
@ -152,25 +152,25 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera
CBotLogicExpr* inst = new CBotLogicExpr();
inst->m_condition = left;
p = p->GivNext(); // skip the token of the operation
p = p->GetNext(); // skip the token of the operation
inst->m_op1 = CBotExpression::Compile(p, pStk);
CBotToken* pp = p;
if ( inst->m_op1 == NULL || !IsOfType( p, ID_DOTS ) )
{
pStk->SetError( TX_MISDOTS, p->GivStart());
pStk->SetError( TX_MISDOTS, p->GetStart());
delete inst;
return pStack->Return(NULL, pStk);
}
type1 = pStk->GivTypResult();
type1 = pStk->GetTypResult();
inst->m_op2 = CBotExpression::Compile(p, pStk);
if ( inst->m_op2 == NULL )
{
pStk->SetError( TX_ENDOF, p->GivStart() );
pStk->SetError( TX_ENDOF, p->GetStart() );
delete inst;
return pStack->Return(NULL, pStk);
}
type2 = pStk->GivTypResult();
type2 = pStk->GetTypResult();
if (!TypeCompatible(type1, type2))
{
pStk->SetError( TX_BAD2TYPE, pp );
@ -187,7 +187,7 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera
inst->SetToken(p); // stores the operation
p = p->GivNext(); // skip the token of the operation
p = p->GetNext(); // skip the token of the operation
// looking statements that may be suitable for right
@ -196,10 +196,10 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera
{
// there is an second operand acceptable
type2 = pStk->GivTypResult(); // what kind of results?
type2 = pStk->GetTypResult(); // what kind of results?
// what kind of result?
int TypeRes = MAX( type1.GivType(3), type2.GivType(3) );
int TypeRes = MAX( type1.GetType(3), type2.GetType(3) );
if ( TypeOp == ID_ADD && type1.Eq(CBotTypString) )
{
TypeRes = CBotTypString;
@ -232,17 +232,17 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera
inst->m_leftop = left;
// special for evaluation of the operations of the same level from left to right
while ( IsInList( p->GivType(), pOperations, typemasque ) ) // same operation(s) follows?
while ( IsInList( p->GetType(), pOperations, typemasque ) ) // same operation(s) follows?
{
TypeOp = p->GivType();
TypeOp = p->GetType();
CBotTwoOpExpr* i = new CBotTwoOpExpr(); // element for operation
i->SetToken(p); // stores the operation
i->m_leftop = inst; // left operand
type1 = TypeRes;
p = p->GivNext(); // advance after
p = p->GetNext(); // advance after
i->m_rightop = CBotTwoOpExpr::Compile( p, pStk, pOp );
type2 = pStk->GivTypResult();
type2 = pStk->GetTypResult();
if ( !TypeCompatible (type1, type2, TypeOp) ) // the results are compatible
{
@ -252,14 +252,14 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera
}
if ( TypeRes != CBotTypString )
TypeRes = MAX(type1.GivType(), type2.GivType());
TypeRes = MAX(type1.GetType(), type2.GetType());
inst = i;
}
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);
@ -283,7 +283,7 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera
bool IsNan(CBotVar* left, CBotVar* right, int* err = NULL)
{
if ( left ->GivInit() > IS_DEF || right->GivInit() > IS_DEF )
if ( left ->GetInit() > IS_DEF || right->GetInit() > IS_DEF )
{
if ( err != NULL ) *err = TX_OPNAN ;
return true;
@ -302,21 +302,21 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
// according to recovery, it may be in one of two states
if ( pStk1->GivState() == 0 ) // first state, evaluates the left operand
if ( pStk1->GetState() == 0 ) // first state, evaluates the left operand
{
if (!m_leftop->Execute(pStk1) ) return false; // interrupted here?
// for OR and AND logic does not evaluate the second expression if not necessary
if ( (GivTokenType() == ID_LOG_AND || GivTokenType() == ID_TXT_AND ) && pStk1->GivVal() == false )
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 ( (GivTokenType() == ID_LOG_OR||GivTokenType() == ID_TXT_OR) && pStk1->GivVal() == true )
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
@ -334,28 +334,28 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
// or return in case of recovery
// 2e état, évalue l'opérande de droite
if ( pStk2->GivState() == 0 )
if ( pStk2->GetState() == 0 )
{
if ( !m_rightop->Execute(pStk2) ) return false; // interrupted here?
pStk2->IncState();
}
CBotTypResult type1 = pStk1->GivTypResult(); // what kind of results?
CBotTypResult type2 = pStk2->GivTypResult();
CBotTypResult type1 = pStk1->GetTypResult(); // what kind of results?
CBotTypResult type2 = pStk2->GetTypResult();
CBotStack* pStk3 = pStk2->AddStack(this); // adds an item to the stack
if ( pStk3->IfStep() ) return false; // shows the operation if step by step
// creates a temporary variable to put the result
// what kind of result?
int TypeRes = MAX(type1.GivType(), type2.GivType());
int TypeRes = MAX(type1.GetType(), type2.GetType());
if ( GivTokenType() == ID_ADD && type1.Eq(CBotTypString) )
if ( GetTokenType() == ID_ADD && type1.Eq(CBotTypString) )
{
TypeRes = CBotTypString;
}
switch ( GivTokenType() )
switch ( GetTokenType() )
{
case ID_LOG_OR:
case ID_LOG_AND:
@ -374,12 +374,12 @@ 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.GivType(), type2.GivType());
TypeRes = MAX(type1.GetType(), type2.GetType());
if ( GivTokenType() == ID_ADD && type1.Eq(CBotTypString) )
if ( GetTokenType() == ID_ADD && type1.Eq(CBotTypString) )
{
TypeRes = CBotTypString;
}
@ -387,15 +387,15 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
CBotVar* temp;
if ( TypeRes == CBotTypPointer ) TypeRes = CBotTypNullPointer;
if ( TypeRes == CBotTypClass ) temp = CBotVar::Create( (CBotToken*)NULL, CBotTypResult(CBotTypIntrinsic, type1.GivClass() ) );
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
CBotVar* left = pStk1->GivVar();
CBotVar* right = pStk2->GivVar();
CBotVar* left = pStk1->GetVar();
CBotVar* right = pStk2->GetVar();
switch (GivTokenType())
switch (GetTokenType())
{
case ID_ADD:
if ( !IsNan(left, right, &err) ) result->Add(left , right); // addition
@ -433,13 +433,13 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
break;
case ID_EQ:
if ( IsNan(left, right) )
result->SetValInt(left->GivInit() == right->GivInit()) ;
result->SetValInt(left->GetInit() == right->GetInit()) ;
else
result->SetValInt(temp->Eq(left , right)); // equal
break;
case ID_NE:
if ( IsNan(left, right) )
result->SetValInt(left ->GivInit() != right->GivInit()) ;
result->SetValInt(left ->GetInit() != right->GetInit()) ;
else
result->SetValInt(temp->Ne(left , right)); // different
break;
@ -485,7 +485,7 @@ void CBotTwoOpExpr::RestoreState(CBotStack* &pStack, bool bMain)
// according to recovery, it may be in one of two states
if ( pStk1->GivState() == 0 ) // first state, evaluates the left operand
if ( pStk1->GetState() == 0 ) // first state, evaluates the left operand
{
m_leftop->RestoreState(pStk1, bMain); // interrupted here!
return;
@ -495,7 +495,7 @@ void CBotTwoOpExpr::RestoreState(CBotStack* &pStack, bool bMain)
if ( pStk2 == NULL ) return;
// second state, evaluates the right operand
if ( pStk2->GivState() == 0 )
if ( pStk2->GetState() == 0 )
{
m_rightop->RestoreState(pStk2, bMain); // interrupted here!
return;
@ -509,13 +509,13 @@ bool CBotLogicExpr::Execute(CBotStack* &pStack)
// or return in case of recovery
// if ( pStk1 == EOX ) return true;
if ( pStk1->GivState() == 0 )
if ( pStk1->GetState() == 0 )
{
if ( !m_condition->Execute(pStk1) ) return false;
if (!pStk1->SetState(1)) return false;
}
if ( pStk1->GivVal() == true )
if ( pStk1->GetVal() == true )
{
if ( !m_op1->Execute(pStk1) ) return false;
}
@ -534,13 +534,13 @@ void CBotLogicExpr::RestoreState(CBotStack* &pStack, bool bMain)
CBotStack* pStk1 = pStack->RestoreStack(this); // adds an item to the stack
if ( pStk1 == NULL ) return;
if ( pStk1->GivState() == 0 )
if ( pStk1->GetState() == 0 )
{
m_condition->RestoreState(pStk1, bMain);
return;
}
if ( pStk1->GivVal() == true )
if ( pStk1->GetVal() == true )
{
m_op1->RestoreState(pStk1, bMain);
}
@ -558,7 +558,7 @@ void t()
}
#endif
#if 01
#if 0
void t(bool t)
{
int x;

File diff suppressed because it is too large Load Diff

View File

@ -55,7 +55,7 @@ CBotInstr* CBotWhile::Compile(CBotToken* &p, CBotCStack* pStack)
if ( IsOfType( p, TokenTypVar ) &&
IsOfType( p, ID_DOTS ) )
{
inst->m_label = pp->GivString(); // records the name of the label
inst->m_label = pp->GetString(); // records the name of the label
}
inst->SetToken(p);
@ -95,7 +95,7 @@ bool CBotWhile :: Execute(CBotStack* &pj)
if ( pile->IfStep() ) return false;
while( true ) switch( pile->GivState() ) // executes the loop
while( true ) switch( pile->GetState() ) // executes the loop
{ // there are two possible states (depending on recovery)
case 0:
// evaluates the condition
@ -104,7 +104,7 @@ bool CBotWhile :: Execute(CBotStack* &pj)
// the result of the condition is on the stack
// terminates if an error or if the condition is false
if ( !pile->IsOk() || pile->GivVal() != true )
if ( !pile->IsOk() || pile->GetVal() != true )
{
return pj->Return(pile); // sends the results and releases the stack
}
@ -140,7 +140,7 @@ void CBotWhile :: RestoreState(CBotStack* &pj, bool bMain)
CBotStack* pile = pj->RestoreStack(this); // adds an item to the stack
if ( pile == NULL ) return;
switch( pile->GivState() )
switch( pile->GetState() )
{ // there are two possible states (depending on recovery)
case 0:
// evaluates the condition
@ -181,7 +181,7 @@ CBotInstr* CBotRepeat::Compile(CBotToken* &p, CBotCStack* pStack)
if ( IsOfType( p, TokenTypVar ) &&
IsOfType( p, ID_DOTS ) )
{
inst->m_label = pp->GivString(); // register the name of label
inst->m_label = pp->GetString(); // register the name of label
}
inst->SetToken(p);
@ -194,7 +194,7 @@ CBotInstr* CBotRepeat::Compile(CBotToken* &p, CBotCStack* pStack)
CBotToken* ppp = p; // preserves the ^ token (starting position)
if ( NULL != (inst->m_NbIter = CBotExpression::Compile( p, pStk )) )
{
if ( pStk->GivType() < CBotTypLong )
if ( pStk->GetType() < CBotTypLong )
{
if ( IsOfType(p, ID_CLOSEPAR ) )
{
@ -210,14 +210,14 @@ CBotInstr* CBotRepeat::Compile(CBotToken* &p, CBotCStack* pStack)
return pStack->Return(inst, pStk); // return an object to the application
}
}
pStack->SetError(TX_CLOSEPAR, p->GivStart());
pStack->SetError(TX_CLOSEPAR, p->GetStart());
}
pStk->SetStartError(ppp->GivStart());
pStk->SetError( TX_BADTYPE, p->GivStart() );
pStk->SetStartError(ppp->GetStart());
pStk->SetError( TX_BADTYPE, p->GetStart() );
}
pStack->SetError(TX_ENDOF, p);
}
pStack->SetError(TX_OPENPAR, p->GivStart()); // missing parenthesis
pStack->SetError(TX_OPENPAR, p->GetStart()); // missing parenthesis
delete inst; // error, frees up
return pStack->Return(NULL, pStk); // no object, the error is on the stack
@ -233,7 +233,7 @@ bool CBotRepeat :: Execute(CBotStack* &pj)
if ( pile->IfStep() ) return false;
while( true ) switch( pile->GivState() ) // executes the loop
while( true ) switch( pile->GetState() ) // executes the loop
{ // there are two possible states (depending on recovery)
case 0:
// evaluates the number of iterations
@ -243,7 +243,7 @@ bool CBotRepeat :: Execute(CBotStack* &pj)
// terminates if an error or if the condition is false
int n;
if ( !pile->IsOk() || ( n = pile->GivVal() ) < 1 )
if ( !pile->IsOk() || ( n = pile->GetVal() ) < 1 )
{
return pj->Return(pile); // sends the results and releases the stack
}
@ -262,7 +262,7 @@ bool CBotRepeat :: Execute(CBotStack* &pj)
if ( m_Block != NULL &&
!m_Block->Execute(pile) )
{
if (pile->IfContinue(pile->GivState()-1, m_label)) continue; // if continued, will return to test
if (pile->IfContinue(pile->GetState()-1, m_label)) continue; // if continued, will return to test
return pj->BreakReturn(pile, m_label); // sends the results and releases the stack
}
@ -273,7 +273,7 @@ bool CBotRepeat :: Execute(CBotStack* &pj)
}
// returns to the test again
if (!pile->SetState(pile->GivState()-1, 0)) return false;
if (!pile->SetState(pile->GetState()-1, 0)) return false;
continue;
}
}
@ -284,7 +284,7 @@ void CBotRepeat :: RestoreState(CBotStack* &pj, bool bMain)
CBotStack* pile = pj->RestoreStack(this); // adds an item to the stack
if ( pile == NULL ) return;
switch( pile->GivState() )
switch( pile->GetState() )
{ // there are two possible states (depending on recovery)
case 0:
// evaluates the condition
@ -325,7 +325,7 @@ CBotInstr* CBotDo::Compile(CBotToken* &p, CBotCStack* pStack)
if ( IsOfType( p, TokenTypVar ) &&
IsOfType( p, ID_DOTS ) )
{
inst->m_label = pp->GivString(); // register the name of label
inst->m_label = pp->GetString(); // register the name of label
}
inst->SetToken(p);
@ -350,10 +350,10 @@ CBotInstr* CBotDo::Compile(CBotToken* &p, CBotCStack* pStack)
{
return pStack->Return(inst, pStk); // return an object to the application
}
pStk->SetError(TX_ENDOF, p->GivStart());
pStk->SetError(TX_ENDOF, p->GetStart());
}
}
pStk->SetError(TX_WHILE, p->GivStart());
pStk->SetError(TX_WHILE, p->GetStart());
}
delete inst; // error, frees up
@ -370,7 +370,7 @@ bool CBotDo :: Execute(CBotStack* &pj)
if ( pile->IfStep() ) return false;
while( true ) switch( pile->GivState() ) // executes the loop
while( true ) switch( pile->GetState() ) // executes the loop
{ // there are two possible states (depending on recovery)
case 0:
// evaluates the associated statement block
@ -396,7 +396,7 @@ bool CBotDo :: Execute(CBotStack* &pj)
// the result of the condition is on the stack
// terminates if an error or if the condition is false
if ( !pile->IsOk() || pile->GivVal() != true )
if ( !pile->IsOk() || pile->GetVal() != true )
{
return pj->Return(pile); // sends the results and releases the stack
}
@ -414,7 +414,7 @@ void CBotDo :: RestoreState(CBotStack* &pj, bool bMain)
CBotStack* pile = pj->RestoreStack(this); // adds an item to the stack
if ( pile == NULL ) return;
switch( pile->GivState() )
switch( pile->GetState() )
{ // there are two possible states (depending on recovery)
case 0:
// restores the assosiated statement's block
@ -459,7 +459,7 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack)
if ( IsOfType( p, TokenTypVar ) &&
IsOfType( p, ID_DOTS ) )
{
inst->m_label = pp->GivString(); // register the name of label
inst->m_label = pp->GetString(); // register the name of label
}
inst->SetToken(p);
@ -467,7 +467,7 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack)
if ( !IsOfType(p, ID_OPENPAR)) // missing parenthesis ?
{
pStack->SetError(TX_OPENPAR, p->GivStart());
pStack->SetError(TX_OPENPAR, p->GetStart());
return NULL;
}
@ -479,7 +479,7 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack)
{
if ( !IsOfType(p, ID_SEP)) // lack the semicolon?
{
pStack->SetError(TX_OPENPAR, p->GivStart());
pStack->SetError(TX_OPENPAR, p->GetStart());
delete inst;
return pStack->Return(NULL, pStk); // no object, the error is on the stack
}
@ -488,7 +488,7 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack)
{
if ( !IsOfType(p, ID_SEP)) // lack the semicolon?
{
pStack->SetError(TX_OPENPAR, p->GivStart());
pStack->SetError(TX_OPENPAR, p->GetStart());
delete inst;
return pStack->Return(NULL, pStk); // no object, the error is on the stack
}
@ -503,7 +503,7 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack)
if ( pStk->IsOk() )
return pStack->Return(inst, pStk);;
}
pStack->SetError(TX_CLOSEPAR, p->GivStart());
pStack->SetError(TX_CLOSEPAR, p->GetStart());
}
}
}
@ -522,7 +522,7 @@ bool CBotFor :: Execute(CBotStack* &pj)
if ( pile->IfStep() ) return false;
while( true ) switch( pile->GivState() ) // executes the loop
while( true ) switch( pile->GetState() ) // executes the loop
{ // there are four possible states (depending on recovery)
case 0:
// initialize
@ -539,7 +539,7 @@ bool CBotFor :: Execute(CBotStack* &pj)
// the result of the condition is on the stack
// terminates if an error or if the condition is false
if ( !pile->IsOk() || pile->GivVal() != true )
if ( !pile->IsOk() || pile->GetVal() != true )
{
return pj->Return(pile); // sends the results and releases the stack
}
@ -583,7 +583,7 @@ void CBotFor :: RestoreState(CBotStack* &pj, bool bMain)
CBotStack* pile = pj->RestoreStack(this); // adds an item to the stack (variables locales)
if ( pile == NULL ) return;
switch( pile->GivState() )
switch( pile->GetState() )
{ // there are four possible states (depending on recovery)
case 0:
// initialize
@ -669,13 +669,13 @@ bool CBotListExpression::Execute(CBotStack* &pj)
CBotStack* pile = pj->AddStack(); // essential
CBotInstr* p = m_Expr; // the first expression
int state = pile->GivState();
while (state-->0) p = p->GivNext(); // returns to the interrupted operation
int state = pile->GetState();
while (state-->0) p = p->GetNext(); // returns to the interrupted operation
if ( p != NULL ) while (true)
{
if ( !p->Execute(pile) ) return false;
p = p->GivNext();
p = p->GetNext();
if ( p == NULL ) break;
if (!pile->IncState()) return false; // ready for next
}
@ -691,7 +691,7 @@ void CBotListExpression::RestoreState(CBotStack* &pj, bool bMain)
{
pile = pj->RestoreStack();
if ( pile == NULL ) return;
state = pile->GivState();
state = pile->GetState();
}
CBotInstr* p = m_Expr; // the first expression
@ -699,7 +699,7 @@ void CBotListExpression::RestoreState(CBotStack* &pj, bool bMain)
while (p != NULL && state-->0)
{
p->RestoreState(pile, false);
p = p->GivNext(); // returns to the interrupted operation
p = p->GetNext(); // returns to the interrupted operation
}
if ( p != NULL )
@ -741,7 +741,7 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack)
{
if ( NULL != (inst->m_Value = CBotExpression::Compile( p, pStk )) )
{
if ( pStk->GivType() < CBotTypLong )
if ( pStk->GetType() < CBotTypLong )
{
if ( IsOfType(p, ID_CLOSEPAR ) )
{
@ -751,7 +751,7 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack)
while( !IsOfType( p, ID_CLBLK ) )
{
if ( p->GivType() == ID_CASE || p->GivType() == ID_DEFAULT)
if ( p->GetType() == ID_CASE || p->GetType() == ID_DEFAULT)
{
CBotCStack* pStk2 = pStk->TokenStack(p); // un petit bout de pile svp
@ -769,7 +769,7 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack)
if ( inst->m_Block == NULL )
{
pStk->SetError(TX_NOCASE, p->GivStart());
pStk->SetError(TX_NOCASE, p->GetStart());
delete inst;
return pStack->Return(NULL, pStk);
}
@ -793,21 +793,21 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack)
if ( inst->m_Block == NULL )
{
pStk->SetError(TX_NOCASE, p->GivStart());
pStk->SetError(TX_NOCASE, p->GetStart());
delete inst;
return pStack->Return(NULL, pStk);
}
// the statement block is ok
return pStack->Return(inst, pStk); // return an object to the application
}
pStk->SetError( TX_OPENBLK, p->GivStart() );
pStk->SetError( TX_OPENBLK, p->GetStart() );
}
pStk->SetError( TX_CLOSEPAR, p->GivStart() );
pStk->SetError( TX_CLOSEPAR, p->GetStart() );
}
pStk->SetError( TX_BADTYPE, p->GivStart() );
pStk->SetError( TX_BADTYPE, p->GetStart() );
}
}
pStk->SetError( TX_OPENPAR, p->GivStart());
pStk->SetError( TX_OPENPAR, p->GetStart());
delete inst; // error, frees up
return pStack->Return(NULL, pStk); // no object, the error is on the stack
@ -822,7 +822,7 @@ bool CBotSwitch :: Execute(CBotStack* &pj)
CBotInstr* p = m_Block; // first expression
int state = pile1->GivState();
int state = pile1->GetState();
if (state == 0)
{
if ( !m_Value->Execute(pile1) ) return false;
@ -834,14 +834,14 @@ bool CBotSwitch :: Execute(CBotStack* &pj)
if ( state == -1 )
{
state = 0;
int val = pile1->GivVal(); // result of the value
int val = pile1->GetVal(); // result of the value
CBotStack* pile2 = pile1->AddStack();
while ( p != NULL ) // search for the corresponding case in a list
{
state++;
if ( p->CompCase( pile2, val ) ) break; // found the case
p = p->GivNext();
p = p->GetNext();
}
pile2->Delete();
@ -851,13 +851,13 @@ bool CBotSwitch :: Execute(CBotStack* &pj)
}
p = m_Block; // returns to the beginning
while (state-->0) p = p->GivNext(); // advance in the list
while (state-->0) p = p->GetNext(); // advance in the list
while( p != NULL )
{
if ( !p->Execute(pile1) ) return pj->BreakReturn(pile1);
if ( !pile1->IncState() ) return false;
p = p->GivNext();
p = p->GetNext();
}
return pj->Return(pile1);
}
@ -871,7 +871,7 @@ void CBotSwitch :: RestoreState(CBotStack* &pj, bool bMain)
CBotInstr* p = m_Block; // first expression
int state = pile1->GivState();
int state = pile1->GetState();
if (state == 0)
{
m_Value->RestoreState(pile1, bMain);
@ -887,7 +887,7 @@ void CBotSwitch :: RestoreState(CBotStack* &pj, bool bMain)
while ( p != NULL && state-- > 0 )
{
p->RestoreState(pile1, false);
p = p->GivNext(); // advance in the list
p = p->GetNext(); // advance in the list
}
if( p != NULL )
@ -923,7 +923,7 @@ CBotInstr* CBotCase::Compile(CBotToken* &p, CBotCStack* pStack)
inst->SetToken(p);
if (!IsOfType(p, ID_CASE, ID_DEFAULT)) return NULL; // should never happen
if ( pp->GivType() == ID_CASE )
if ( pp->GetType() == ID_CASE )
{
pp = p;
inst->m_Value = CBotExprNum::Compile(p, pStack);
@ -936,7 +936,7 @@ CBotInstr* CBotCase::Compile(CBotToken* &p, CBotCStack* pStack)
}
if ( !IsOfType( p, ID_DOTS ))
{
pStack->SetError( TX_MISDOTS, p->GivStart() );
pStack->SetError( TX_MISDOTS, p->GetStart() );
delete inst;
return NULL;
}
@ -963,7 +963,7 @@ bool CBotCase::CompCase(CBotStack* &pile, int val)
if ( m_Value == NULL ) return true; // "default" case
while (!m_Value->Execute(pile)); // puts the value on the correspondent stack (without interruption)
return (pile->GivVal() == val); // compared with the given value
return (pile->GetVal() == val); // compared with the given value
}
///////////////////////////////////////////////////////////////////////////
@ -983,7 +983,7 @@ CBotBreak::~CBotBreak()
CBotInstr* CBotBreak::Compile(CBotToken* &p, CBotCStack* pStack)
{
CBotToken* pp = p; // preserves at the ^ token (starting position)
int type = p->GivType();
int type = p->GetType();
if (!IsOfType(p, ID_BREAK, ID_CONTINUE)) return NULL; // should never happen
@ -999,7 +999,7 @@ CBotInstr* CBotBreak::Compile(CBotToken* &p, CBotCStack* pStack)
pp = p;
if ( IsOfType( p, TokenTypVar ) )
{
inst->m_label = pp->GivString(); // register the name of label
inst->m_label = pp->GetString(); // register the name of label
if ( !ChkLvl(inst->m_label, type ) )
{
delete inst;
@ -1014,7 +1014,7 @@ CBotInstr* CBotBreak::Compile(CBotToken* &p, CBotCStack* pStack)
}
delete inst;
pStack->SetError(TX_ENDOF, p->GivStart());
pStack->SetError(TX_ENDOF, p->GetStart());
return NULL; // no object, the error is on the stack
}
@ -1027,7 +1027,7 @@ bool CBotBreak :: Execute(CBotStack* &pj)
if ( pile->IfStep() ) return false;
pile->SetBreak(m_token.GivType()==ID_BREAK ? 1 : 2, m_label);
pile->SetBreak(m_token.GetType()==ID_BREAK ? 1 : 2, m_label);
return pj->Return(pile);
}
@ -1070,7 +1070,7 @@ CBotInstr* CBotTry::Compile(CBotToken* &p, CBotCStack* pStack)
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk );
CBotCatch** pn = &inst->m_ListCatch;
while (pStk->IsOk() && p->GivType() == ID_CATCH)
while (pStk->IsOk() && p->GetType() == ID_CATCH)
{
CBotCatch* i = CBotCatch::Compile(p, pStk);
*pn = i;
@ -1108,7 +1108,7 @@ bool CBotTry :: Execute(CBotStack* &pj)
CBotStack* pile0 = pj->AddStack2(); // adds an element to the secondary stack
CBotStack* pile2 = pile0->AddStack();
if ( pile1->GivState() == 0 )
if ( pile1->GetState() == 0 )
{
if ( m_Block->Execute(pile1) )
{
@ -1116,7 +1116,7 @@ bool CBotTry :: Execute(CBotStack* &pj)
pile1->SetState(-2); // passes final
}
val = pile1->GivError();
val = pile1->GetError();
if ( val == 0 && CBotStack::m_initimer == 0 ) // mode step?
return false; // does not make the catch
@ -1132,8 +1132,8 @@ bool CBotTry :: Execute(CBotStack* &pj)
// see what it returns
CBotCatch* pc = m_ListCatch;
int state = (short)pile1->GivState(); // where were we?
val = pile2->GivState(); // what error?
int state = static_cast<short>(pile1->GetState()); // where were we?
val = pile2->GetState(); // what error?
pile0->SetState(1); // marking the GetRunPos
if ( val >= 0 && state > 0 ) while ( pc != NULL )
@ -1147,7 +1147,7 @@ bool CBotTry :: Execute(CBotStack* &pj)
}
if ( --state <= 0 )
{
if ( pile2->GivVal() == true )
if ( pile2->GetVal() == true )
{
// pile0->SetState(1);
@ -1163,15 +1163,15 @@ bool CBotTry :: Execute(CBotStack* &pj)
pc = pc->m_next;
}
if ( m_FinalInst != NULL &&
pile1->GivState() > 0 && val != 0 ) pile1->SetState(-1);// if stop then made the final
pile1->GetState() > 0 && val != 0 ) pile1->SetState(-1);// if stop then made the final
if (pile1->GivState() <= -1)
if (pile1->GetState() <= -1)
{
// pile0->SetState(1);
if (!m_FinalInst->Execute(pile2) && pile2->IsOk()) return false;
if (!pile2->IsOk()) return pj->Return(pile2); // keep this exception
pile2->SetError(pile1->GivState()==-1 ? val : 0); // gives the initial error
pile2->SetError(pile1->GetState()==-1 ? val : 0); // gives the initial error
return pj->Return(pile2);
}
@ -1200,7 +1200,7 @@ void CBotTry :: RestoreState(CBotStack* &pj, bool bMain)
if ( pile2 == NULL ) return;
m_Block->RestoreState(pile1, bMain);
if ( pile0->GivState() == 0 )
if ( pile0->GetState() == 0 )
{
return;
}
@ -1209,8 +1209,8 @@ void CBotTry :: RestoreState(CBotStack* &pj, bool bMain)
// see what it returns
CBotCatch* pc = m_ListCatch;
int state = pile1->GivState(); // where were we ?
val = pile2->GivState(); // what error ?
int state = pile1->GetState(); // where were we ?
val = pile2->GetState(); // what error ?
if ( val >= 0 && state > 0 ) while ( pc != NULL )
{
@ -1223,7 +1223,7 @@ void CBotTry :: RestoreState(CBotStack* &pj, bool bMain)
}
if ( --state <= 0 )
{
if ( pile2->GivVal() == true )
if ( pile2->GetVal() == true )
{
pc->RestoreState(pile2, bMain); // execute the operation
return;
@ -1232,7 +1232,7 @@ void CBotTry :: RestoreState(CBotStack* &pj, bool bMain)
pc = pc->m_next;
}
if (pile1->GivState() <= -1)
if (pile1->GetState() <= -1)
{
m_FinalInst->RestoreState(pile2, bMain);
return;
@ -1263,7 +1263,7 @@ CBotCatch::~CBotCatch()
CBotCatch* CBotCatch::Compile(CBotToken* &p, CBotCStack* pStack)
{
CBotCatch* inst = new CBotCatch(); // creates the object
pStack->SetStartError(p->GivStart());
pStack->SetStartError(p->GetStart());
inst->SetToken(p);
if (!IsOfType(p, ID_CATCH)) return NULL; // should never happen
@ -1271,8 +1271,8 @@ CBotCatch* CBotCatch::Compile(CBotToken* &p, CBotCStack* pStack)
if (IsOfType(p, ID_OPENPAR))
{
inst->m_Cond = CBotExpression::Compile(p, pStack);
if (( pStack->GivType() < CBotTypLong ||
pStack->GivTypResult().Eq(CBotTypBoolean) )&& pStack->IsOk() )
if (( pStack->GetType() < CBotTypLong ||
pStack->GetTypResult().Eq(CBotTypBoolean) )&& pStack->IsOk() )
{
if (IsOfType(p, ID_CLOSEPAR))
{
@ -1280,11 +1280,11 @@ CBotCatch* CBotCatch::Compile(CBotToken* &p, CBotCStack* pStack)
if ( pStack->IsOk() )
return inst; // return an object to the application
}
pStack->SetError(TX_CLOSEPAR, p->GivStart());
pStack->SetError(TX_CLOSEPAR, p->GetStart());
}
pStack->SetError(TX_BADTYPE, p->GivStart());
pStack->SetError(TX_BADTYPE, p->GetStart());
}
pStack->SetError(TX_OPENPAR, p->GivStart());
pStack->SetError(TX_OPENPAR, p->GetStart());
delete inst; // error, frees up
return NULL; // no object, the error is on the stack
}
@ -1313,10 +1313,10 @@ bool CBotCatch :: TestCatch(CBotStack* &pile, int val)
{
if ( !m_Cond->Execute(pile) ) return false;
if ( val > 0 || pile->GivType() != CBotTypBoolean )
if ( val > 0 || pile->GetType() != CBotTypBoolean )
{
CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypBoolean);
var->SetValInt( pile->GivVal() == val );
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(NULL), CBotTypBoolean);
var->SetValInt( pile->GetVal() == val );
pile->SetVar(var); // calls on the stack
}
@ -1342,7 +1342,7 @@ CBotThrow::~CBotThrow()
CBotInstr* CBotThrow::Compile(CBotToken* &p, CBotCStack* pStack)
{
pStack->SetStartError(p->GivStart());
pStack->SetStartError(p->GetStart());
CBotThrow* inst = new CBotThrow(); // creates the object
inst->SetToken(p);
@ -1353,7 +1353,7 @@ CBotInstr* CBotThrow::Compile(CBotToken* &p, CBotCStack* pStack)
inst->m_Value = CBotExpression::Compile( p, pStack );
if (pStack->GivType() < CBotTypLong && pStack->IsOk())
if (pStack->GetType() < CBotTypLong && pStack->IsOk())
{
return inst; // return an object to the application
}
@ -1370,7 +1370,7 @@ bool CBotThrow :: Execute(CBotStack* &pj)
CBotStack* pile = pj->AddStack(this);
// if ( pile == EOX ) return true;
if ( pile->GivState() == 0 )
if ( pile->GetState() == 0 )
{
if ( !m_Value->Execute(pile) ) return false;
pile->IncState();
@ -1378,7 +1378,7 @@ bool CBotThrow :: Execute(CBotStack* &pj)
if ( pile->IfStep() ) return false;
int val = pile->GivVal();
int val = pile->GetVal();
if ( val < 0 ) val = TX_BADTHROW;
pile->SetError( val, &m_token );
return pj->Return( pile );
@ -1391,7 +1391,7 @@ void CBotThrow :: RestoreState(CBotStack* &pj, bool bMain)
CBotStack* pile = pj->RestoreStack(this);
if ( pile == NULL ) return;
if ( pile->GivState() == 0 )
if ( pile->GetState() == 0 )
{
m_Value->RestoreState(pile, bMain);
return;
@ -1425,7 +1425,7 @@ CBotInstr* CBotStartDebugDD::Compile(CBotToken* &p, CBotCStack* pStack)
bool CBotStartDebugDD :: Execute(CBotStack* &pj)
{
CBotProgram* p = pj->GivBotCall();
CBotProgram* p = pj->GetBotCall();
p->m_bDebugDD = true;
return true;

View File

@ -68,25 +68,25 @@ bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exceptio
if ( pVar == NULL ) return true;
// must be a string
if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
if ( pVar->GetType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
CBotString filename = pVar->GivValString();
CBotString filename = pVar->GetValString();
PrepareFilename(filename); //DR
// there may be a second parameter
pVar = pVar->GivNext();
pVar = pVar->GetNext();
if ( pVar != NULL )
{
// recovers the mode
mode = pVar->GivValString();
mode = pVar->GetValString();
if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return false; }
// no third parameter, only two or one possible
if ( pVar->GivNext() != NULL ) { Exception = CBotErrOverParam; return false; }
if ( pVar->GetNext() != NULL ) { Exception = CBotErrOverParam; return false; }
}
// save the file name
pVar = pThis->GivItem("filename");
pVar = pThis->GetItem("filename");
pVar->SetValString(filename);
if ( ! mode.IsEmpty() )
@ -98,7 +98,7 @@ bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exceptio
m_CompteurFileOpen ++;
// save the handle of file
pVar = pThis->GivItem("handle");
pVar = pThis->GetItem("handle");
pVar->SetValInt((long)pFile);
}
@ -112,18 +112,18 @@ CBotTypResult cfconstruct (CBotVar* pThis, CBotVar* &pVar)
if ( pVar == NULL ) return CBotTypResult( 0 );
// must be a string
if ( pVar->GivType() != CBotTypString )
if ( pVar->GetType() != CBotTypString )
return CBotTypResult( CBotErrBadString );
// there may be a second parameter
pVar = pVar->GivNext();
pVar = pVar->GetNext();
if ( pVar != NULL )
{
// must be a string
if ( pVar->GivType() != CBotTypString )
if ( pVar->GetType() != CBotTypString )
return CBotTypResult( CBotErrBadString );
// no third parameter
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
if ( pVar->GetNext() != NULL ) return CBotTypResult( CBotErrOverParam );
}
// le r<>sultat est de type void (constructeur)
@ -137,12 +137,12 @@ CBotTypResult cfconstruct (CBotVar* pThis, CBotVar* &pVar)
bool rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{
// retrieves the element "handle"
pVar = pThis->GivItem("handle");
pVar = pThis->GetItem("handle");
// not open? no problem
if ( pVar->GivInit() != IS_DEF) return true;
if ( pVar->GetInit() != IS_DEF) return true;
FILE* pFile= (FILE*)pVar->GivValInt();
FILE* pFile= (FILE*)pVar->GetValInt();
fclose(pFile);
m_CompteurFileOpen --;
@ -162,38 +162,38 @@ bool rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
// must be a string
if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
if ( pVar->GetType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
// there may be a second parameter
if ( pVar->GivNext() != NULL )
if ( pVar->GetNext() != NULL )
{
// in this case the first parameter is the file name
CBotString filename = pVar->GivValString();
CBotString filename = pVar->GetValString();
PrepareFilename(filename); //DR
// saves the file name
CBotVar* pVar2 = pThis->GivItem("filename");
CBotVar* pVar2 = pThis->GetItem("filename");
pVar2->SetValString(filename);
// next parameter is the mode
pVar = pVar -> GivNext();
pVar = pVar -> GetNext();
}
CBotString mode = pVar->GivValString();
CBotString mode = pVar->GetValString();
if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return false; }
// No third parameter
if ( pVar->GivNext() != NULL ) { Exception = CBotErrOverParam; return false; }
if ( pVar->GetNext() != NULL ) { Exception = CBotErrOverParam; return false; }
// retrieves the element "handle"
pVar = pThis->GivItem("handle");
pVar = pThis->GetItem("handle");
// which must not be initialized
if ( pVar->GivInit() == IS_DEF) { Exception = CBotErrFileOpen; return false; }
if ( pVar->GetInit() == IS_DEF) { Exception = CBotErrFileOpen; return false; }
// contains filename
pVar = pThis->GivItem("filename");
CBotString filename = pVar->GivValString();
pVar = pThis->GetItem("filename");
CBotString filename = pVar->GetValString();
PrepareFilename(filename); //DD! (if the name was assigned by h.filename = "...";
@ -208,7 +208,7 @@ bool rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
m_CompteurFileOpen ++;
// saves the handle of file
pVar = pThis->GivItem("handle");
pVar = pThis->GetItem("handle");
pVar->SetValInt((long)pFile);
pResult->SetValInt(true); //DR
@ -222,19 +222,19 @@ CBotTypResult cfopen (CBotVar* pThis, CBotVar* &pVar)
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
// must be a string
if ( pVar->GivType() != CBotTypString )
if ( pVar->GetType() != CBotTypString )
return CBotTypResult( CBotErrBadString );
// there may be a second parameter
pVar = pVar->GivNext();
pVar = pVar->GetNext();
if ( pVar != NULL )
{
// must be a string
if ( pVar->GivType() != CBotTypString )
if ( pVar->GetType() != CBotTypString )
return CBotTypResult( CBotErrBadString );
// no third parameter
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
if ( pVar->GetNext() != NULL ) return CBotTypResult( CBotErrOverParam );
}
// the result is of type bool
@ -251,11 +251,11 @@ bool rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
if ( pVar != NULL ) return CBotErrOverParam;
// retrieves the element "handle"
pVar = pThis->GivItem("handle");
pVar = pThis->GetItem("handle");
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
FILE* pFile= (FILE*)pVar->GivValInt();
FILE* pFile= (FILE*)pVar->GetValInt();
fclose(pFile);
m_CompteurFileOpen --;
@ -283,16 +283,16 @@ bool rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
// must be a string
if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
if ( pVar->GetType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
CBotString param = pVar->GivValString();
CBotString param = pVar->GetValString();
//retrieves the element "handle"
pVar = pThis->GivItem("handle");
pVar = pThis->GetItem("handle");
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
FILE* pFile= (FILE*)pVar->GivValInt();
FILE* pFile= (FILE*)pVar->GetValInt();
int res = fputs(param+CBotString("\n"), pFile);
@ -309,10 +309,10 @@ CBotTypResult cfwrite (CBotVar* pThis, CBotVar* &pVar)
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
// must be a string
if ( pVar->GivType() != CBotTypString ) return CBotTypResult( CBotErrBadString );
if ( pVar->GetType() != CBotTypString ) return CBotTypResult( CBotErrBadString );
// no other parameter
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
if ( pVar->GetNext() != NULL ) return CBotTypResult( CBotErrOverParam );
// function returns "void" result
return CBotTypResult( 0 );
@ -327,11 +327,11 @@ bool rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
//retrieves the element "handle"
pVar = pThis->GivItem("handle");
pVar = pThis->GetItem("handle");
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
FILE* pFile= (FILE*)pVar->GivValInt();
FILE* pFile= (FILE*)pVar->GetValInt();
char chaine[2000];
int i;
@ -368,11 +368,11 @@ bool rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
// retrieves the element "handle"
pVar = pThis->GivItem("handle");
pVar = pThis->GetItem("handle");
if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
FILE* pFile= (FILE*)pVar->GivValInt();
FILE* pFile= (FILE*)pVar->GetValInt();
pResult->SetValInt( feof( pFile ) );

View File

@ -26,16 +26,16 @@ bool rStrLen( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// to be a string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
if ( pVar->GetType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// no second parameter
if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return true; }
if ( pVar->GetNext() != NULL ) { ex = TX_OVERPARAM ; return true; }
// get the contents of the string
CBotString s = pVar->GivValString();
CBotString s = pVar->GetValString();
// puts the length of the stack
pResult->SetValInt( s.GivLength() );
pResult->SetValInt( s.GetLength() );
return true;
}
@ -48,11 +48,11 @@ CBotTypResult cIntStr( CBotVar* &pVar, void* pUser )
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
// to be a string
if ( pVar->GivType() != CBotTypString )
if ( pVar->GetType() != CBotTypString )
return CBotTypResult( TX_BADPARAM );
// no second parameter
if ( pVar->GivNext() != NULL ) return CBotTypResult( TX_OVERPARAM );
if ( pVar->GetNext() != NULL ) return CBotTypResult( TX_OVERPARAM );
// the end result is an integer
return CBotTypResult( CBotTypInt );
@ -68,23 +68,23 @@ bool rStrLeft( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// to be a string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
if ( pVar->GetType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// get the contents of the string
CBotString s = pVar->GivValString();
CBotString s = pVar->GetValString();
// it takes a second parameter
pVar = pVar->GivNext();
pVar = pVar->GetNext();
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// which must be a number
if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; }
if ( pVar->GetType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; }
// retrieves this number
int n = pVar->GivValInt();
int n = pVar->GetValInt();
// no third parameter
if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return true; }
if ( pVar->GetNext() != NULL ) { ex = TX_OVERPARAM ; return true; }
// takes the interesting part
s = s.Left( n );
@ -103,19 +103,19 @@ CBotTypResult cStrStrInt( CBotVar* &pVar, void* pUser )
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
// to be a string
if ( pVar->GivType() != CBotTypString )
if ( pVar->GetType() != CBotTypString )
return CBotTypResult( TX_BADSTRING );
// it takes a second parameter
pVar = pVar->GivNext();
pVar = pVar->GetNext();
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
// which must be a number
if ( pVar->GivType() > CBotTypDouble )
if ( pVar->GetType() > CBotTypDouble )
return CBotTypResult( TX_BADNUM );
// no third parameter
if ( pVar->GivNext() != NULL ) return CBotTypResult( TX_OVERPARAM );
if ( pVar->GetNext() != NULL ) return CBotTypResult( TX_OVERPARAM );
// the end result is a string
return CBotTypResult( CBotTypString );
@ -130,23 +130,23 @@ bool rStrRight( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// to be a string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
if ( pVar->GetType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// get the contents of the string
CBotString s = pVar->GivValString();
CBotString s = pVar->GetValString();
// it takes a second parameter
pVar = pVar->GivNext();
pVar = pVar->GetNext();
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// which must be a number
if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; }
if ( pVar->GetType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; }
// retrieves this number
int n = pVar->GivValInt();
int n = pVar->GetValInt();
// no third parameter
if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return true; }
if ( pVar->GetNext() != NULL ) { ex = TX_OVERPARAM ; return true; }
// takes the interesting part
s = s.Right( n );
@ -165,34 +165,34 @@ bool rStrMid( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// to be a string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
if ( pVar->GetType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// get the contents of the string
CBotString s = pVar->GivValString();
CBotString s = pVar->GetValString();
// it takes a second parameter
pVar = pVar->GivNext();
pVar = pVar->GetNext();
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// which must be a number
if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; }
if ( pVar->GetType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; }
// retrieves this number
int n = pVar->GivValInt();
int n = pVar->GetValInt();
// third parameter optional
if ( pVar->GivNext() != NULL )
if ( pVar->GetNext() != NULL )
{
pVar = pVar->GivNext();
pVar = pVar->GetNext();
// which must be a number
if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; }
if ( pVar->GetType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; }
// retrieves this number
int l = pVar->GivValInt();
int l = pVar->GetValInt();
// but no fourth parameter
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
if ( pVar->GetNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
// takes the interesting part
s = s.Mid( n, l );
@ -217,28 +217,28 @@ CBotTypResult cStrStrIntInt( CBotVar* &pVar, void* pUser )
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
// to be a string
if ( pVar->GivType() != CBotTypString )
if ( pVar->GetType() != CBotTypString )
return CBotTypResult( TX_BADSTRING );
// it takes a second parameter
pVar = pVar->GivNext();
pVar = pVar->GetNext();
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
// which must be a number
if ( pVar->GivType() > CBotTypDouble )
if ( pVar->GetType() > CBotTypDouble )
return CBotTypResult( TX_BADNUM );
// third parameter optional
if ( pVar->GivNext() != NULL )
if ( pVar->GetNext() != NULL )
{
pVar = pVar->GivNext();
pVar = pVar->GetNext();
// which must be a number
if ( pVar->GivType() > CBotTypDouble )
if ( pVar->GetType() > CBotTypDouble )
return CBotTypResult( TX_BADNUM );
// no fourth parameter
if ( pVar->GivNext() != NULL ) return CBotTypResult( TX_OVERPARAM );
if ( pVar->GetNext() != NULL ) return CBotTypResult( TX_OVERPARAM );
}
// the end result is a string
@ -255,15 +255,15 @@ bool rStrVal( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// to be a string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
if ( pVar->GetType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// get the contents of the string
CBotString s = pVar->GivValString();
CBotString s = pVar->GetValString();
// but no second parameter
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
if ( pVar->GetNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
float val = GivNumFloat(s);
float val = GetNumFloat(s);
// puts the value on the stack
pResult->SetValFloat( val );
@ -279,11 +279,11 @@ CBotTypResult cFloatStr( CBotVar* &pVar, void* pUser )
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
// to be a string
if ( pVar->GivType() != CBotTypString )
if ( pVar->GetType() != CBotTypString )
return CBotTypResult( TX_BADSTRING );
// no second parameter
if ( pVar->GivNext() != NULL ) return CBotTypResult( TX_OVERPARAM );
if ( pVar->GetNext() != NULL ) return CBotTypResult( TX_OVERPARAM );
// the end result is a number
return CBotTypResult( CBotTypFloat );
@ -299,23 +299,23 @@ bool rStrFind( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// to be a string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
if ( pVar->GetType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// get the contents of the string
CBotString s = pVar->GivValString();
CBotString s = pVar->GetValString();
// it takes a second parameter
pVar = pVar->GivNext();
pVar = pVar->GetNext();
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// to be a string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
if ( pVar->GetType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// retrieves this number
CBotString s2 = pVar->GivValString();
CBotString s2 = pVar->GetValString();
// no third parameter
if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return true; }
if ( pVar->GetNext() != NULL ) { ex = TX_OVERPARAM ; return true; }
// puts the result on the stack
int res = s.Find(s2);
@ -333,19 +333,19 @@ CBotTypResult cIntStrStr( CBotVar* &pVar, void* pUser )
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
// to be a string
if ( pVar->GivType() != CBotTypString )
if ( pVar->GetType() != CBotTypString )
return CBotTypResult( TX_BADSTRING );
// it takes a second parameter
pVar = pVar->GivNext();
pVar = pVar->GetNext();
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
// to be a string
if ( pVar->GivType() != CBotTypString )
if ( pVar->GetType() != CBotTypString )
return CBotTypResult( TX_BADSTRING );
// no third parameter
if ( pVar->GivNext() != NULL ) return CBotTypResult( TX_OVERPARAM );
if ( pVar->GetNext() != NULL ) return CBotTypResult( TX_OVERPARAM );
// the end result is a number
return CBotTypResult( CBotTypInt );
@ -360,13 +360,13 @@ bool rStrUpper( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// to be a string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
if ( pVar->GetType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// get the contents of the string
CBotString s = pVar->GivValString();
CBotString s = pVar->GetValString();
// but no second parameter
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
if ( pVar->GetNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
s.MakeUpper();
@ -385,13 +385,13 @@ bool rStrLower( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// to be a string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
if ( pVar->GetType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// get the contents of the string
CBotString s = pVar->GivValString();
CBotString s = pVar->GetValString();
// but no second parameter
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
if ( pVar->GetNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
s.MakeLower();
@ -410,11 +410,11 @@ CBotTypResult cStrStr( CBotVar* &pVar, void* pUser )
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
// to be a string
if ( pVar->GivType() != CBotTypString )
if ( pVar->GetType() != CBotTypString )
return CBotTypResult( TX_BADSTRING );
// no second parameter
if ( pVar->GivNext() != NULL ) return CBotTypResult( TX_OVERPARAM );
if ( pVar->GetNext() != NULL ) return CBotTypResult( TX_OVERPARAM );
// the end result is a string
return CBotTypResult( CBotTypString );

View File

@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 2.8)
project(CBot_console C CXX)
# Build with debugging symbols
set(CMAKE_BUILD_TYPE debug)
# Global compile flags
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall -Wold-style-cast -std=gnu++0x")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wold-style-cast -std=gnu++0x")
# Include cmake directory
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${colobot_SOURCE_DIR}/cmake")
add_subdirectory(src bin)

View File

@ -0,0 +1 @@
../../../../CBot/

View File

@ -0,0 +1,32 @@
# CBot shared library is built separately
add_subdirectory(CBot)
# Configure options
option(DEBUG "Enable debug output" ON)
set(PLATFORM_LIBS "")
# Source files
# Commented out files are still dependent on DirectX or WinAPI
set(SOURCES
app/CClass.cpp
app/main.cpp
#app/routines.cpp
app/CBotDoc.cpp
app/CBotConsole.cpp
)
set(LIBS
CBot
)
include_directories(. ${CMAKE_CURRENT_BINARY_DIR}
)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot)
add_executable(CBot_console ${SOURCES})
target_link_libraries(CBot_console ${LIBS})

View File

@ -0,0 +1,175 @@
/*
* CBotConsole.cpp
*
* Created on: 08-08-2012
* Author: michal
*/
#include "CBotConsole.h"
#include "CClass.h"
#include <ctime>
#include <iostream>
CBotConsole::CBotConsole() {
// TODO Auto-generated constructor stub
m_pProg = NULL;
m_threadinfo.m_bRun = false;
m_code = 0;
}
CBotConsole::~CBotConsole() {
// TODO Auto-generated destructor stub
}
uint ThreadProc(ThreadInfo *info)
{
time_t t0,t1;
time(&t0);
int Cpt = 0;
info->m_pProg->Start("LaCommande");
while ( !info->m_bStop && !info->m_pProg->Run() )
{
#if 0
const char* FunctionName;
const char* FN;
int start, end;
info->m_pProg->GetRunPos(FunctionName, start, end);
if ( FunctionName != NULL )
{
info->m_pEditx->SetSel(start, end);
char buffer[200];
sprintf( buffer, "step %s, %d, %d",FunctionName, start, end);
AfxMessageBox( buffer );
int level = 0;
do
{
CBotVar* t = info->m_pProg->GetStackVars(FN, level--);
if ( FN != FunctionName ) break;
if ( t != NULL )
{
CString s ;
while ( t != NULL )
{
if (s.IsEmpty()) s+= "Stack -> ";
else s+= " , ";
s += t->GetValString();
t = t->GetNext();
}
AfxMessageBox(s);
}
} while (TRUE);
}
#endif
Cpt++;
if ( Cpt%50 == 0 ) std::cout << ".";
}
if ( info->m_bStop )
{
std::cout << "\nInterrupt\n";
}
else if (info->m_pProg->GetError() == 0)
{
time(&t1);
double prog_time = difftime(t0,t1);
char buffer[200];
sprintf( buffer, "\nExecution terminated in %f seconds.\nInterrupted %d time(s).\n",
prog_time, Cpt);
std::cout << buffer;
}
// info->m_pWndMessage->SendMessage(WM_ENDPROG, 0, 0) ;
return 0 ;
}
long CBotConsole::EndProg()
{
m_threadinfo.m_bRun = false;
if (m_pProg->GetError(m_code, m_start, m_end))
{
CBotString TextError;
TextError = CBotProgram::GetErrorText(m_code);
std::cout << TextError;
return 1;
}
delete m_pProg;
m_pProg = NULL;
return 0 ;
}
void CBotConsole::OnOK()
{
m_code = 0;
std::string Commande;
std::cin >> Commande;
std::string s = "void LaCommande() { " + Commande + " ;}";
m_pProg = new CBotProgram();
CBotStringArray liste;
m_pProg->Compile(s.c_str(), liste);
int err, start, end;
if ( m_pProg->GetError(err, start, end) )
{
CBotString TextError;
TextError = CBotProgram::GetErrorText(err);
std::cout << TextError;
return;
}
std::cout << "\n" + Commande + " ->\n";
// m_Edit2.SetWindowText("");
// m_Edit1.SetFocus();
// m_Edit2.EnableWindow(FALSE);
// m_cOK.EnableWindow(FALSE);
// lance un processus paralèle pour l'exécution
// m_threadinfo.m_pWndMessage = this ;
// m_threadinfo.m_pEdit1 = &m_Edit1;
// m_threadinfo.m_pEditx = m_pEditx;
m_threadinfo.m_pProg = m_pProg;
m_threadinfo.m_bStop = false;
m_threadinfo.m_bRun = true;
ThreadProc(&m_threadinfo);
// here program starts
// AfxBeginThread((AFX_THREADPROC)ThreadProc, &m_threadinfo) ;
}
void CBotConsole::OnCancel()
{
m_threadinfo.m_bStop = true ;
}
bool CBotConsole::OnInitDialog()
{
// CDialog::OnInitDialog();
std::cout << "Following functions are availible:\n";
for ( int i = 0; i < m_pListe->GetSize(); i++ )
{
CBotString x = (*m_pListe)[i] + CBotString("\n");
std::cout << x;
}
std::cout << "Enter a command:\n";
return true; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

View File

@ -0,0 +1,44 @@
/*
* CBotConsole.h
*
* Created on: 08-08-2012
* Author: michal
*/
#ifndef CBOTCONSOLE_H_
#define CBOTCONSOLE_H_
#include "CClass.h"
struct ThreadInfo
{
// CEdit* m_pEdit1 ;
// CEdit* m_pEditx ;
CBotProgram* m_pProg;
// CWnd* m_pWndMessage;
bool m_bStop;
bool m_bRun;
};
class CBotConsole {
public:
CBotConsole();
virtual ~CBotConsole();
// CEdit m_Edit1;
CBotProgram* m_pProg;
ThreadInfo m_threadinfo;
CBotStringArray* m_pListe;
int m_code, m_start, m_end;
// CEdit* m_pEditx;
// Implementation
void OnOK();
void OnCancel();
bool OnInitDialog();
long EndProg() ;
};
#endif /* CBOTCONSOLE_H_ */

View File

@ -0,0 +1,122 @@
/*
* CBotDoc.cpp
*
* Created on: 08-08-2012
* Author: michal
*/
#include "CBotDoc.h"
#include "CBotConsole.h"
#include <iostream>
CBotDoc::CBotDoc(std::string s) {
// TODO Auto-generated constructor stub
// TODO set m_DocText
// m_pEdit = NULL;
m_pProg = NULL;
// m_bModified = FALSE;
m_DocText = s;
std::cout << s << std::endl;
// std::cout << "Enter to continue..." << std::endl;
// getchar();
}
CBotDoc::~CBotDoc() {
// delete m_pEdit;
delete m_pProg;
}
//static bool test = false;
void CBotDoc::OnRun()
{
// m_pEdit->GetWindowText(m_DocText);
CBotString s;
std::string TextError;
int code, start, end;
if ( m_pProg == NULL ) m_pProg = new CBotProgram();
if (!m_pProg->Compile(m_DocText.c_str(), m_Liste, NULL))
{
m_pProg->GetError(code, start, end);
delete m_pProg;
m_pProg = NULL;
TextError = CBotProgram::GetErrorText( code );
std::cout << TextError << std::endl;
return;
}
if( m_Liste.GetSize() == 0 )
{
std::cout << "No function marked \"extern\" !\n";
return;
}
for ( int i = 0; i < m_Liste.GetSize(); i++ )
{
int start, stop;
m_pProg->GetPosition(m_Liste[i], start, stop, GetPosNom, GetPosParam);
CBotString s(m_DocText.substr( start, stop-start ).c_str());
m_Liste[i] = s;
}
// TODO
CBotConsole dlg;
dlg.m_pListe = &m_Liste;
// dlg.m_pEditx = m_pEdit;
dlg.OnInitDialog();
dlg.OnOK();
dlg.EndProg();
// if ( dlg.m_code>0 )
// {
// std::string TextError;
//
// TextError = m_pProg->GetErrorText( dlg.m_code );
//
// std::cout <<TextError;
// }
return;
}
bool CBotDoc::Compile()
{
// m_pEdit->GetWindowText(m_DocText);
std::string TextError;
int code, start, end;
if ( m_pProg == NULL ) m_pProg = new CBotProgram();
char buffer[100];
strcpy(buffer, "a pointer move to see");
if (!m_pProg->Compile(m_DocText.c_str(), m_Liste, static_cast<void*>(buffer)))
{
m_pProg->GetError(code, start, end);
delete m_pProg;
m_pProg = NULL;
// m_pEdit->SetSel( start, end );
// m_pEdit->SetFocus(); // higlights part of problem
TextError = CBotProgram::GetErrorText( code );
std::cout << TextError ;
return false;
}
// if ( m_pProg->GetPosition( "TheTest", start, end) )
// {
// m_pEdit->SetSel( start, end );
// m_pEdit->SetFocus(); // higlights part of problem
// }
// m_bModified = FALSE;
return true;
}

View File

@ -0,0 +1,39 @@
/*
* CBotDoc.h
*
* Created on: 08-08-2012
* Author: michal
*/
#pragma once
#ifndef CBOTDOC_H_
#define CBOTDOC_H_
#include "CClass.h"
#include <string>
class CBotDoc {
public:
CBotDoc(std::string);
virtual ~CBotDoc();
// CEdit* m_pEdit; // to memorize the text, and display
CBotProgram* m_pProg; // the compiled program
std::string m_DocText;
CBotStringArray m_Liste;
// Operations
bool Compile();
// virtual bool OnNewDocument();
void OnRun();
void OnChangeEdit1();
void OnTest();
};
#endif /* CBOTDOC_H_ */

View File

@ -0,0 +1,97 @@
#include "CClass.h"
#include "routines.cpp"
void rMajObject( CBotVar* pThis, void* pUser )
{
if (!pThis->IsElemOfClass("object"))
return ;
CBotVar* pPos = pThis->GetItem("position");
CBotVar* pX = pPos->GetItem("x");
CBotVar* pY = pPos->GetItem("y");
CBotVar* pZ = pPos->GetItem("z");
// CBotVar* pPt = pThis->GetItem("transport");
CBotString p = pX->GetValString();
// pX->SetValFloat( pUser == (void*)1 ? (float)12.5 : (float)44.4 );
pZ->SetValFloat( (float)0 );
pY->SetValFloat( (float)-3.33 );
pX->SetValFloat( pX->GetValFloat() + 10 ) ;
// pX = pThis->GetItem( "xx" );
// pX->SetValFloat( (float)22 );
// crée une instance sur une classe object
// CBotVar* pAutre = CBotVar::Create("autre", CBotTypClass, "object");
// pAutre->SetUserPtr( (void*)3 );
// pPt->SetPointer( pAutre );
// pPt->SetPointer( NULL );
// delete pAutre;
};
CClass::CClass()
{
m_pClassPoint= NULL;
}
bool CClass::InitInstance()
{
//////////////////////////////////////////////
// défini les mots clefs supplémentaires
// -------------------------------------------
CBotProgram::Init();
//////////////////////////////////////////////
// défini les fonctions "show()" et "print()"
// -------------------------------------------
//CBotProgram::AddFunction("show", rShow, cShow);
CBotProgram::AddFunction("print", rPrint, cPrint);
CBotProgram::AddFunction("println", rPrintLn, cPrint);
///////////////////////////////////
// définie la classe globale CPoint
// --------------------------------
m_pClassPoint = new CBotClass("CPoint", NULL);
// ajoute le composant ".x"
m_pClassPoint->AddItem("x", CBotTypFloat);
// ajoute le composant ".y"
m_pClassPoint->AddItem("y", CBotTypFloat);
// ajoute le constructeur pour cette classe
m_pClassPoint->AddFunction("CPoint", rCPoint, cCPoint);
m_pClassPointIntr = new CBotClass("point", NULL, true);
// ajoute le composant ".x"
m_pClassPointIntr->AddItem("x", CBotTypFloat);
// ajoute le composant ".y"
m_pClassPointIntr->AddItem("y", CBotTypFloat);
// ajoute le composant ".z"
m_pClassPointIntr->AddItem("z", CBotTypFloat);
// ajoute le constructeur pour cette classe
m_pClassPointIntr->AddFunction("point", rCPoint, cCPoint);
// défini la classe "object"
CBotClass* pClassObject = new CBotClass( "object", NULL ) ;
pClassObject->AddItem( "xx", CBotTypFloat );
pClassObject->AddItem( "position", CBotTypResult( CBotTypIntrinsic, "point" ) );
pClassObject->AddItem( "transport", CBotTypResult( CBotTypPointer, "object" ) );
pClassObject->AddUpdateFunc( rMajObject );
InitClassFILE();
return true;
}
void CClass::ExitInstance()
{
delete m_pFuncFile;
CBotProgram::Free();
}

View File

@ -0,0 +1,18 @@
#pragma once
#include <CBot/CBot.h>
#include <string>
extern std::string s;
class CClass
{
public:
CClass();
CBotClass* m_pClassPoint;
CBotClass* m_pClassPointIntr;
bool InitInstance();
void ExitInstance();
};

View File

@ -0,0 +1,45 @@
#include "CClass.h"
#include "CBotDoc.h"
#include <iostream>
#include <fstream>
std::string str;
// routine to update the instance of the class Bot common
int main(int argc, char* argv[])
{
CClass newclass;
CBotDoc *botdoc;
if (argc != 2)
{
std::cout << "Usage: "<<argv[0] << " <filename>" << std::endl;
return 0;
}
std::ifstream in(argv[1]);
std::cout << argv[1] << std::endl;
if (!in.good())
{
std::cout << "Oh no, error!" << std::endl;
return 1;
}
std::string contents((std::istreambuf_iterator<char>(in)),
std::istreambuf_iterator<char>());
str = contents;
if(!newclass.InitInstance())
{
std::cerr << "Initialization not complete!" << std::endl;
return 1;
}
botdoc = new CBotDoc(str);
// std::cout << "Hello CBot!" << std::endl << s;
botdoc->OnRun();
delete botdoc;
newclass.ExitInstance();
}

View File

@ -0,0 +1,141 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * 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://www.gnu.org/licenses/.
////////////////////////////////////////////////////////////////////
// routine show()
// utilisable depuis le programme écrit en CBot
#include <iostream>
#include <string>
#include "CBot/ClassFILE.cpp"
//std::string s;
/*
// execution
bool rShow( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
{
string::string s;
while ( pVar != NULL )
{
string::string ss;
ss.LoadString( TX_TYPENAMES + pVar->GetType() );
s += ss + " ";
ss = pVar->GetName();
if (ss.IsEmpty()) ss = "<sans nom>";
s += ss + " = ";
s += pVar->GetValString();
s += "\n";
pVar = pVar->GetNext();
}
AfxMessageBox(s, MB_OK|MB_ICONINFORMATION);
return TRUE; // pas d'interruption
}
CBotTypResult cShow( CBotVar* &pVar, void* pUser)
{
if ( pVar == NULL ) return CBotTypResult(5028);
return CBotTypResult(0); // tous paramètres acceptés, void en retour
}
*/
////////////////////////////////////////////////////////////////////
// routine print()
// utilisable depuis le programme écrit en CBot
// exécution
bool rPrintLn( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
{
std::string s;
while ( pVar != NULL )
{
if ( !s.empty() ) s += " ";
s += pVar->GetValString();
pVar = pVar->GetNext();
}
s += "\n";
std::cout << s;
return true; // pas d'interruption
}
bool rPrint( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
{
std::string s;
while ( pVar != NULL )
{
if ( !s.empty() ) s += " ";
s += pVar->GetValString();
pVar = pVar->GetNext();
}
s += " ";
std::cout << s;
return true; // pas d'interruption
}
CBotTypResult cPrint( CBotVar* &pVar, void* pUser)
{
return CBotTypResult(0); // tous paramètres acceptés, un entier en retour
}
//////////////////////////////////////////////////////////////////
// class CPoint pour essayer
// exécution
bool rCPoint( CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception )
{
if ( pVar == NULL )return true; // constructor with no parameters is ok
CBotVar* pX = pThis->GetItem("x");
pX->SetValFloat( pVar->GetValFloat() );
pVar = pVar->GetNext();
CBotVar* pY = pThis->GetItem("y");
pY->SetValFloat( pVar->GetValFloat() );
pVar = pVar->GetNext();
return true; // pas d'interruption
}
CBotTypResult cCPoint( CBotVar* pThis, CBotVar* &pVar)
{
// ok if no parameters!
if ( pVar == NULL ) return CBotTypResult(0);
// numeric type of parameter please
if ( pVar->GetType() > CBotTypDouble ) return CBotTypResult(5011);
pVar = pVar->GetNext();
// there must be a second parameter
if ( pVar == NULL ) return 5028;
// also numeric
if ( pVar->GetType() > CBotTypDouble )return CBotTypResult(5011);
pVar = pVar->GetNext();
// and not more than 2 parameters please
if ( pVar != NULL ) return CBotTypResult(5026);
return CBotTypResult(0); // This function returns void
}

View File

@ -1,164 +0,0 @@
// BotConsoleDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TstCBot.h"
#include "BotConsoleDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBotConsoleDlg dialog
CBotConsoleDlg::CBotConsoleDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBotConsoleDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CBotConsoleDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pProg = NULL;
m_threadinfo.m_bRun = FALSE;
}
void CBotConsoleDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBotConsoleDlg)
DDX_Control(pDX, IDOK, m_cOK);
DDX_Control(pDX, IDC_EDIT2, m_Edit2);
DDX_Control(pDX, IDC_EDIT1, m_Edit1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBotConsoleDlg, CDialog)
//{{AFX_MSG_MAP(CBotConsoleDlg)
ON_MESSAGE(WM_ENDPROG, EndProg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBotConsoleDlg message handlers
UINT ThreadProc(ThreadInfo *info)
{
CTime t0 = CTime::GetCurrentTime();
int Cpt = 0;
info->m_pProg->Start("LaCommande");
while ( !info->m_bStop && !info->m_pProg->Run() )
{
Cpt++;
if ( Cpt%20 == 0 ) info->m_pEdit1->ReplaceSel(".");
}
if ( info->m_bStop )
{
info->m_pEdit1->ReplaceSel("\r\nInterrompu\r\n");
}
else if (info->m_pProg->GivError() == 0)
{
CTime t = CTime::GetCurrentTime();
CTimeSpan ts = t - t0;
char buffer[200];
sprintf( buffer, "\r\nExécution terminée en %d secondes.\r\nInterrompue %d fois.\r\n",
ts.GetTotalSeconds(), Cpt);
info->m_pEdit1->ReplaceSel(buffer);
}
info->m_pWndMessage->SendMessage(WM_ENDPROG, 0, 0) ;
return 0 ;
}
LONG CBotConsoleDlg::EndProg(UINT wparam, LONG lparam)
{
m_threadinfo.m_bRun = FALSE;
if (m_pProg->GetError(m_code, m_start, m_end))
{
AfxMessageBox(m_code);
CDialog::OnCancel();
return 1;
}
delete m_pProg;
m_pProg = NULL;
m_Edit2.EnableWindow(TRUE);
m_cOK.EnableWindow(TRUE);
m_Edit2.SetWindowText("");
m_Edit2.SetFocus();
return 0 ;
}
void CBotConsoleDlg::OnOK()
{
CTstCBotApp* pApp = (CTstCBotApp*)AfxGetApp();
pApp->m_pConsole = &m_Edit1;
CString Commande;
m_Edit2.GetWindowText(Commande);
CString s = "void LaCommande() { " + Commande + " ;}";
m_pProg = new CBotProgram();
CBotStringArray liste;
m_pProg->Compile(s, liste);
int err, start, end;
if ( m_pProg->GetError(err, start, end) )
{
AfxMessageBox(err);
m_Edit2.SetSel(start-20, end-20);
return;
}
m_Edit1.ReplaceSel(Commande + " ->\r\n");
m_Edit2.SetWindowText("");
m_Edit1.SetFocus();
m_Edit2.EnableWindow(FALSE);
m_cOK.EnableWindow(FALSE);
// lance un processus paralèle pour l'exécution
m_threadinfo.m_pWndMessage = this ;
m_threadinfo.m_pEdit1 = &m_Edit1;
m_threadinfo.m_pProg = m_pProg;
m_threadinfo.m_bStop = FALSE;
m_threadinfo.m_bRun = TRUE;
AfxBeginThread((AFX_THREADPROC)ThreadProc, &m_threadinfo) ;
}
void CBotConsoleDlg::OnCancel()
{
if (!m_threadinfo.m_bRun) CDialog::OnCancel();
m_threadinfo.m_bStop = TRUE ;
}
BOOL CBotConsoleDlg::OnInitDialog()
{
CTstCBotApp* pApp = (CTstCBotApp*)AfxGetApp();
CDialog::OnInitDialog();
m_Edit1.ReplaceSel("Les fonctions suivantes sont disponibles:\r\n");
for ( int i = 0; i < pApp->m_Liste.RetSize(); i++ )
{
CBotString x = CString(pApp->m_Liste[i]) + "\r\n";
m_Edit1.ReplaceSel(x);
}
m_Edit1.ReplaceSel("Entrez une commande ci-dessous.\r\n\r\n");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

View File

@ -1,65 +0,0 @@
#if !defined(AFX_BOTCONSOLEDLG_H__A11450A2_8E09_11D4_A439_00D059085115__INCLUDED_)
#define AFX_BOTCONSOLEDLG_H__A11450A2_8E09_11D4_A439_00D059085115__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// BotConsoleDlg.h : header file
//
struct ThreadInfo
{
CEdit* m_pEdit1 ;
CBotProgram* m_pProg;
CWnd* m_pWndMessage;
BOOL m_bStop;
BOOL m_bRun;
};
/////////////////////////////////////////////////////////////////////////////
// CBotConsoleDlg dialog
class CBotConsoleDlg : public CDialog
{
// Construction
public:
CBotConsoleDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CBotConsoleDlg)
enum { IDD = IDD_CONSOLE };
CButton m_cOK;
CEdit m_Edit2;
CEdit m_Edit1;
//}}AFX_DATA
CBotProgram* m_pProg;
ThreadInfo m_threadinfo;
int m_code, m_start, m_end;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBotConsoleDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CBotConsoleDlg)
virtual void OnOK();
virtual void OnCancel();
virtual BOOL OnInitDialog();
afx_msg LONG EndProg(UINT wparam, LONG lparam) ;
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BOTCONSOLEDLG_H__A11450A2_8E09_11D4_A439_00D059085115__INCLUDED_)

View File

@ -1,56 +0,0 @@
// BotErrorDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TstCBot.h"
#include "BotErrorDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBotErrorDlg dialog
CBotErrorDlg::CBotErrorDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBotErrorDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CBotErrorDlg)
m_TextProgram = _T("");
//}}AFX_DATA_INIT
}
void CBotErrorDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBotErrorDlg)
DDX_Control(pDX, IDC_EDIT1, m_eProgram);
DDX_Control(pDX, IDC_STATIC1, m_sMessage);
DDX_Text(pDX, IDC_EDIT1, m_TextProgram);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBotErrorDlg, CDialog)
//{{AFX_MSG_MAP(CBotErrorDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBotErrorDlg message handlers
BOOL CBotErrorDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_sMessage.SetWindowText(m_TextError);
m_eProgram.SetFocus();
m_eProgram.SetSel(m_start, m_end);
return FALSE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

View File

@ -1,51 +0,0 @@
#if !defined(AFX_BOTERRORDLG_H__80E73D20_7454_11D4_A439_00D059085115__INCLUDED_)
#define AFX_BOTERRORDLG_H__80E73D20_7454_11D4_A439_00D059085115__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// BotErrorDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CBotErrorDlg dialog
class CBotErrorDlg : public CDialog
{
// Construction
public:
CBotErrorDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CBotErrorDlg)
enum { IDD = IDD_DIALOG1 };
CEdit m_eProgram;
CStatic m_sMessage;
CString m_TextProgram;
//}}AFX_DATA
CString m_TextError;
int m_start, m_end;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBotErrorDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CBotErrorDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BOTERRORDLG_H__80E73D20_7454_11D4_A439_00D059085115__INCLUDED_)

View File

@ -1,36 +0,0 @@
extern void TheTest()
{
for (int x = 130; x>0; x--) print (x);
}
extern void Test()
{
int var = 10000 ;
while (var > 0) var = var -1;
}
// exécuté en 30 secondes
extern void Autre()
{
int var = 10000 ;
while (var > 0) if ( var > 0 ) var = var -1;
}
// exécuté en 45 secondes
int Y ( int n )
{
if ( n < 2 ) return n;
int a = Y(n-1) + Y(n-2);
return a;
}
extern int X ( int n )
{
if ( n < 2 ) { print(n); return n; }
int a = X(n-1) + Y(n-2);
print (a);
return a;
}

View File

@ -1,107 +0,0 @@
// CMyThread.cpp : pour créer un processus pour la console
//
#include "stdafx.h"
#include "TstCBot.h"
#include "CMyThread.h"
#include "BotConsoleDlg.h"
//IMPLEMENT_DYNAMIC (CMyThread, CWinThread)
IMPLEMENT_DYNCREATE (CMyThread, CWinThread)
/////////////////////////////////////////////////////////////////////////////
// CMyThread
BEGIN_MESSAGE_MAP(CMyThread, CWinThread)
//{{AFX_MSG_MAP(CMyThread)
//}}AFX_MSG_MAP
// Standard file based document commands
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyThread construction
CMyThread::CMyThread()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// CMyThread initialization
/*
BOOL CMyThread::InitInstance()
{
AfxEnableControlContainer();
CTstCBotApp* pApp = (CTstCBotApp*)AfxGetApp();
// ouvre une fenêtre pour afficher les sorties
CRect rect;
AfxGetMainWnd()->GetClientRect( rect );
rect += CPoint(30,30);
CWnd* pWnd = new CWnd();
pWnd->CreateEx( 0,
AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)),
"CBot console", WS_POPUPWINDOW|WS_CAPTION|WS_VISIBLE,
rect,
AfxGetMainWnd()->GetParent(), NULL, NULL);
m_pMainWnd = pWnd;
pApp->m_pEdit2 = new CEdit();
m_pMainWnd->GetClientRect( rect );
rect.bottom -= 40;
pApp->m_pEdit2->Create( WS_VISIBLE|WS_BORDER|WS_TABSTOP|ES_MULTILINE|ES_WANTRETURN|
ES_AUTOVSCROLL|ES_READONLY,
rect, m_pMainWnd, IDC_EDIT2 );
pApp->m_pEdit2->ReplaceSel("Les fonctions suivantes sont disponibles:\n\r");
for ( int i = 0; i < pApp->m_Liste.RetSize(); i++ )
{
pApp->m_pEdit2->ReplaceSel(pApp->m_Liste[i] + "\r\n");
}
pApp->m_pEdit2->ReplaceSel("Entrez une commande ci-dessous.\r\r");
// pApp->m_pEdit2->SetFocus();
pApp->m_pEdit3 = new CEdit();
m_pMainWnd->GetClientRect( rect );
rect.top = rect.bottom-40;
pApp->m_pEdit3->Create( WS_VISIBLE|WS_BORDER|WS_TABSTOP,
rect, m_pMainWnd, IDC_EDIT1 );
pApp->m_pEdit3->SetFocus();
return TRUE;
}*/
BOOL CMyThread::InitInstance()
{
CBotConsoleDlg dlg;
m_pMainWnd = &dlg; // cela ferme l'application avec la DBOX !
int nResponse = dlg.DoModal();
return TRUE;
}
int CMyThread::ExitInstance()
{
return 0;
}
/////////////////////////////////////////////////////////////////////////////
// CMyThread message handlers
void CMyThread::OnReturn()
{
// TODO: Add your command handler code here
__asm int 3;
}

View File

@ -1,44 +0,0 @@
// CMyThread.h : pour créer un processus pour la console
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINFRM_H__20B3756C_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)
#define AFX_MAINFRM_H__20B3756C_5DFD_11D4_A15E_00E0189013DF__INCLUDED_
#include "stdafx.h"
#include "TstCBot.h"
class CMyThread : public CWinThread
{
// DECLARE_DYNAMIC(CMyThread)
DECLARE_DYNCREATE(CMyThread)
public:
// Constructor
CMyThread();
virtual BOOL InitInstance();
virtual int ExitInstance(); // return app exit code
// Implementation
//{{AFX_MSG(CTstCBotApp)
afx_msg void OnAppAbout();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg void OnReturn();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__20B3756C_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)

View File

@ -1,91 +0,0 @@
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "TstCBot.h"
#include "MainFrm.h"
#include "BotErrorDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFrameWnd::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers

View File

@ -1,55 +0,0 @@
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINFRM_H__70B3756C_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)
#define AFX_MAINFRM_H__70B3756C_5DFD_11D4_A15E_00E0189013DF__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnCp1();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__70B3756C_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)

View File

@ -1,93 +0,0 @@
========================================================================
MICROSOFT FOUNDATION CLASS LIBRARY : TstCBot
========================================================================
AppWizard has created this TstCBot application for you. This application
not only demonstrates the basics of using the Microsoft Foundation classes
but is also a starting point for writing your application.
This file contains a summary of what you will find in each of the files that
make up your TstCBot application.
TstCBot.h
This is the main header file for the application. It includes other
project specific headers (including Resource.h) and declares the
CTstCBotApp application class.
TstCBot.cpp
This is the main application source file that contains the application
class CTstCBotApp.
TstCBot.rc
This is a listing of all of the Microsoft Windows resources that the
program uses. It includes the icons, bitmaps, and cursors that are stored
in the RES subdirectory. This file can be directly edited in Microsoft
Developer Studio.
res\TstCBot.ico
This is an icon file, which is used as the application's icon. This
icon is included by the main resource file TstCBot.rc.
res\TstCBot.rc2
This file contains resources that are not edited by Microsoft
Developer Studio. You should place all resources not
editable by the resource editor in this file.
TstCBot.clw
This file contains information used by ClassWizard to edit existing
classes or add new classes. ClassWizard also uses this file to store
information needed to create and edit message maps and dialog data
maps and to create prototype member functions.
/////////////////////////////////////////////////////////////////////////////
For the main frame window:
MainFrm.h, MainFrm.cpp
These files contain the frame class CMainFrame, which is derived from
CFrameWnd and controls all SDI frame features.
/////////////////////////////////////////////////////////////////////////////
AppWizard creates one document type and one view:
TstCBotDoc.h, TstCBotDoc.cpp - the document
These files contain your CTstCBotDoc class. Edit these files to
add your special document data and to implement file saving and loading
(via CTstCBotDoc::Serialize).
TstCBotView.h, TstCBotView.cpp - the view of the document
These files contain your CTstCBotView class.
CTstCBotView objects are used to view CTstCBotDoc objects.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named TstCBot.pch and a precompiled types file named StdAfx.obj.
Resource.h
This is the standard header file, which defines new resource IDs.
Microsoft Developer Studio reads and updates this file.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.
If your application uses MFC in a shared DLL, and your application is
in a language other than the operating system's current language, you
will need to copy the corresponding localized resources MFC40XXX.DLL
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory,
and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation.
For example, MFC40DEU.DLL contains resources translated to German.) If you
don't do this, some of the UI elements of your application will remain in the
language of the operating system.
/////////////////////////////////////////////////////////////////////////////

View File

@ -1,68 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by TstCBot.rc
//
#define IDD_ABOUTBOX 100
#define IDR_MAINFRAME 128
#define IDR_TSTCBOTYPE 129
#define IDD_DIALOG1 130
#define IDD_CONSOLE 131
#define IDC_EDIT1 1000
#define TX_TYPENAMES 1000
#define IDC_STATIC1 1001
#define IDC_EDIT2 1002
#define TX_OPENPAR 5000
#define TX_CLOSEPAR 5001
#define TX_NOTBOOL 5002
#define TX_UNDEFVAR 5003
#define TX_BADLEFT 5004
#define TX_ENDOF 5005
#define TX_OUTCASE 5006
#define TX_NOTERM 5007
#define TX_CLOSEBLK 5008
#define TX_ELSEWITHOUTIF 5009
#define TX_OPENBLK 5010
#define TX_BADTYPE 5011
#define TX_REDEFVAR 5012
#define TX_BAD2TYPE 5013
#define TX_UNDEFCALL 5014
#define TX_MISDOTS 5015
#define TX_WHILE 5016
#define TX_BREAK 5017
#define TX_LABEL 5018
#define TX_NOLABEL 5019
#define TX_NOCASE 5020
#define TX_BADNUM 5021
#define TX_VOID 5022
#define TX_NOTYP 5023
#define TX_NOVAR 5024
#define TX_NOFONC 5025
#define TX_OVERPARAM 5026
#define TX_REDEF 5027
#define TX_LOWPARAM 5028
#define TX_BADPARAM 5029
#define TX_NUMPARAM 5030
#define TX_NOITEM 5031
#define TX_DOT 5032
#define TX_NOCONST 5033
#define TX_REDEFCLASS 5034
#define TX_DIVZERO 6000
#define TX_NOTINIT 6001
#define TX_BADTHROW 6002
#define TX_NORETVAL 6003
#define TX_NORUN 6004
#define TX_NOCALL 6005
#define ID_CP1 32771
#define ID_EXE 32772
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 132
#define _APS_NEXT_COMMAND_VALUE 32775
#define _APS_NEXT_CONTROL_VALUE 1002
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -1,6 +0,0 @@
// stdafx.cpp : source file that includes just the standard includes
// TstCBot.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@ -1,26 +0,0 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__70B3756A_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)
#define AFX_STDAFX_H__70B3756A_5DFD_11D4_A15E_00E0189013DF__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC OLE automation classes
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__70B3756A_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)

View File

@ -1,189 +0,0 @@
; CLW file contains information for the MFC ClassWizard
[General Info]
Version=1
LastClass=CTstCBotView
LastTemplate=CDialog
NewFileInclude1=#include "stdafx.h"
NewFileInclude2=#include "TstCBot.h"
LastPage=0
ClassCount=7
Class1=CTstCBotApp
Class2=CTstCBotDoc
Class3=CTstCBotView
Class4=CMainFrame
ResourceCount=6
Resource1=IDD_ABOUTBOX
Resource2=IDR_MAINFRAME
Class5=CAboutDlg
Resource3=IDD_ABOUTBOX (French (France))
Resource4=IDD_CONSOLE
Class6=CBotErrorDlg
Resource5=IDD_DIALOG1 (French (Switzerland))
Class7=CBotConsoleDlg
Resource6=IDR_MAINFRAME (French (France))
[CLS:CTstCBotApp]
Type=0
HeaderFile=TstCBot.h
ImplementationFile=TstCBot.cpp
Filter=N
[CLS:CTstCBotDoc]
Type=0
HeaderFile=TstCBotDoc.h
ImplementationFile=TstCBotDoc.cpp
Filter=N
BaseClass=CDocument
VirtualFilter=DC
LastObject=CTstCBotDoc
[CLS:CTstCBotView]
Type=0
HeaderFile=TstCBotView.h
ImplementationFile=TstCBotView.cpp
Filter=C
BaseClass=CView
VirtualFilter=VWC
LastObject=CTstCBotView
[CLS:CMainFrame]
Type=0
HeaderFile=MainFrm.h
ImplementationFile=MainFrm.cpp
Filter=T
BaseClass=CFrameWnd
VirtualFilter=fWC
LastObject=CMainFrame
[CLS:CAboutDlg]
Type=0
HeaderFile=TstCBot.cpp
ImplementationFile=TstCBot.cpp
Filter=D
[DLG:IDD_ABOUTBOX]
Type=1
Class=CAboutDlg
ControlCount=4
Control1=IDC_STATIC,static,1342177283
Control2=IDC_STATIC,static,1342308480
Control3=IDC_STATIC,static,1342308352
Control4=IDOK,button,1342373889
[MNU:IDR_MAINFRAME]
Type=1
Class=CMainFrame
Command1=ID_FILE_NEW
Command2=ID_FILE_OPEN
Command3=ID_FILE_SAVE
Command4=ID_FILE_SAVE_AS
Command5=ID_FILE_MRU_FILE1
Command6=ID_APP_EXIT
Command7=ID_EDIT_UNDO
Command8=ID_EDIT_CUT
Command9=ID_EDIT_COPY
Command10=ID_EDIT_PASTE
Command11=ID_VIEW_STATUS_BAR
Command12=ID_CP1
Command13=ID_EXE
Command14=ID_APP_ABOUT
CommandCount=14
[ACL:IDR_MAINFRAME]
Type=1
Class=CMainFrame
Command1=ID_CP1
Command2=ID_FILE_NEW
Command3=ID_FILE_OPEN
Command4=ID_FILE_SAVE
Command5=ID_EXE
Command6=ID_EDIT_UNDO
Command7=ID_EDIT_CUT
Command8=ID_EXE
Command9=ID_CP1
Command10=ID_EXE
CommandCount=10
[MNU:IDR_MAINFRAME (French (France))]
Type=1
Class=?
Command1=ID_FILE_NEW
Command2=ID_FILE_OPEN
Command3=ID_FILE_SAVE
Command4=ID_FILE_SAVE_AS
Command5=ID_FILE_MRU_FILE1
Command6=ID_APP_EXIT
Command7=ID_EDIT_UNDO
Command8=ID_EDIT_CUT
Command9=ID_EDIT_COPY
Command10=ID_EDIT_PASTE
Command11=ID_VIEW_STATUS_BAR
Command12=ID_CP1
Command13=ID_EXE
Command14=ID_APP_ABOUT
CommandCount=14
[ACL:IDR_MAINFRAME (French (France))]
Type=1
Class=?
Command1=ID_CP1
Command2=ID_FILE_NEW
Command3=ID_FILE_OPEN
Command4=ID_FILE_SAVE
Command5=ID_EXE
Command6=ID_EDIT_UNDO
Command7=ID_EDIT_CUT
Command8=ID_EXE
Command9=ID_CP1
Command10=ID_EXE
CommandCount=10
[DLG:IDD_ABOUTBOX (French (France))]
Type=1
Class=CAboutDlg
ControlCount=4
Control1=IDC_STATIC,static,1342177283
Control2=IDC_STATIC,static,1342308480
Control3=IDC_STATIC,static,1342308352
Control4=IDOK,button,1342373889
[CLS:CBotErrorDlg]
Type=0
HeaderFile=BotErrorDlg.h
ImplementationFile=BotErrorDlg.cpp
BaseClass=CDialog
Filter=D
VirtualFilter=dWC
LastObject=CBotErrorDlg
[DLG:IDD_DIALOG1 (French (Switzerland))]
Type=1
ControlCount=4
Control1=IDOK,button,1342242817
Control2=IDC_EDIT1,edit,1352728708
Control3=IDC_STATIC,static,1342308352
Control4=IDC_STATIC1,static,1342308352
[DLG:IDD_CONSOLE]
Type=1
Class=CBotConsoleDlg
ControlCount=4
Control1=IDC_STATIC,static,1342308352
Control2=IDC_EDIT2,edit,1350631552
Control3=IDOK,button,1342242817
Control4=IDC_EDIT1,edit,1352734724
[CLS:CBotConsoleDlg]
Type=0
HeaderFile=BotConsoleDlg.h
ImplementationFile=BotConsoleDlg.cpp
BaseClass=CDialog
Filter=D
VirtualFilter=dWC
LastObject=IDOK

View File

@ -1,412 +0,0 @@
// TstCBot.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "TstCBot.h"
#include "MainFrm.h"
#include "TstCBotDoc.h"
#include "TstCBotView.h"
#include "CMyThread.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
////////////////////////////////////////////////////////////////////
// routine show()
// utilisable depuis le programme écrit en CBot
// exécution
BOOL rShow( CBotVar* pVar, CBotVar* pResult, int& Exception )
{
CString s;
if ( pVar == NULL )
{
Exception = 22; return FALSE;
}
while ( pVar != NULL )
{
CString ss;
ss.LoadString( TX_TYPENAMES + pVar->RetType() );
s += ss + " ";
ss = pVar->RetName();
if (ss.IsEmpty()) ss = "<sans nom>";
s += ss + " = ";
s += pVar->RetValString();
s += "\n";
pVar = pVar->RetNext();
}
AfxMessageBox(s, MB_OK|MB_ICONINFORMATION);
// if ( pResult && pResult->RetType() == CBotTypInt) pResult->SetValInt(123);
return TRUE; // pas d'interruption
}
int cShow( CBotVar* &pVar, CBotString& RetClass)
{
if ( pVar == NULL ) return 22;
return CBotTypInt; // tous paramètres acceptés, un entier en retour
}
int cErr( CBotVar* &pVar, CBotString& RetClass)
{
pVar = pVar->RetNext(); // avance le pointeur sur l'erreur
return 6666;
}
////////////////////////////////////////////////////////////////////
// routine print()
// utilisable depuis le programme écrit en CBot
// exécution
BOOL rPrintLn( CBotVar* pVar, CBotVar* pResult, int& Exception )
{
CString s;
CTstCBotApp* pApp = (CTstCBotApp*)AfxGetApp();
CEdit* pEdit = pApp->m_pConsole;
if (pEdit == NULL) return TRUE;
pEdit->GetWindowText(s);
while ( pVar != NULL )
{
if ( !s.IsEmpty() ) s += "\r\n";
s += pVar->RetValString();
pVar = pVar->RetNext();
}
pEdit->SetWindowText(s);
pEdit->SetSel(s.GetLength(), s.GetLength());
pEdit->SetFocus();
return TRUE; // pas d'interruption
}
BOOL rPrint( CBotVar* pVar, CBotVar* pResult, int& Exception )
{
CString s;
CTstCBotApp* pApp = (CTstCBotApp*)AfxGetApp();
CEdit* pEdit = pApp->m_pConsole;
if (pEdit == NULL) return TRUE;
pEdit->GetWindowText(s);
while ( pVar != NULL )
{
if ( !s.IsEmpty() ) s += " ";
s += pVar->RetValString();
pVar = pVar->RetNext();
}
pEdit->SetWindowText(s);
pEdit->SetSel(s.GetLength(), s.GetLength());
pEdit->SetFocus();
return TRUE; // pas d'interruption
}
int cPrint( CBotVar* &pVar, CBotString& RetClass)
{
return 0; // tous paramètres acceptés, un entier en retour
}
//////////////////////////////////////////////////////////////////
// class CPoint pour essayer
// exécution
BOOL rCPoint( CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception )
{
CString s;
if ( pVar == NULL )return TRUE; // constructeur sans paramètres est ok
if ( pVar->RetType() > CBotTypDouble )
{
Exception = 6023; return FALSE;
}
CBotVar* pX = pThis->RetItem("x");
if ( pX == NULL )
{
Exception = 6024; return FALSE;
}
pX->SetValFloat( pVar->RetValFloat() );
pVar = pVar->RetNext();
if ( pVar == NULL )
{
Exception = 6022; return FALSE;
}
if ( pVar->RetType() > CBotTypDouble )
{
Exception = 6023; return FALSE;
}
CBotVar* pY = pThis->RetItem("y");
if ( pY == NULL )
{
Exception = 6024; return FALSE;
}
pY->SetValFloat( pVar->RetValFloat() );
pVar = pVar->RetNext();
if ( pVar != NULL )
{
Exception = 6025; return FALSE;
}
return TRUE; // pas d'interruption
}
int cCPoint( CBotVar* pThis, CBotVar* &pVar, CBotString& RetClass)
{
// l'objet doit être de la classe CPoint
if ( !pThis->IsElemOfClass("CPoint") ) return 6021;
// ok si aucun paramètres !
if ( pVar == NULL ) return 0;
// paramètre de type numérique svp
if ( pVar->RetType() > CBotTypDouble ) return 6023;
pVar = pVar->RetNext();
// il doit y avoir un second paramètre
if ( pVar == NULL ) return 6022;
// également de type numérique
if ( pVar->RetType() > CBotTypDouble )return 6023;
pVar = pVar->RetNext();
// et pas plus de 2 paramètres svp
if ( pVar != NULL ) return 6025;
return 0; // cette fonction retourne void
}
// méthode déterminant l'opposé
BOOL rOppose( CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception )
{
CString s;
if ( pVar != NULL ) // pas de paramètre
{
Exception = 6025; return FALSE;
}
CBotVar* pvar = pThis->RetItemList(); // demande la chaîne des items
// tous les paramètres sont des nombres
while (pvar != NULL)
{
pvar->SetValFloat( -pvar->RetValFloat() );
pvar = pvar->RetNext();
}
pResult->Copy(pThis);
return TRUE; // pas d'interruption
}
int cOppose( CBotVar* pThis, CBotVar* &pVar, CBotString& RetClass)
{
// l'objet doit être de la classe CPoint
if ( !pThis->IsElemOfClass("CPoint") ) return 6021;
RetClass = "CPoint"; // l'objet rendu est de cette class
// ok si aucun paramètres !
if ( pVar == NULL ) return CBotTypClass; // le paramètre retourné est une instance de la classe
return TX_OVERPARAM; // ça va pas
}
/////////////////////////////////////////////////////////////////////////////
// CTstCBotApp
BEGIN_MESSAGE_MAP(CTstCBotApp, CWinApp)
//{{AFX_MSG_MAP(CTstCBotApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTstCBotApp construction
CTstCBotApp::CTstCBotApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CTstCBotApp object
CTstCBotApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CTstCBotApp initialization
BOOL CTstCBotApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CTstCBotDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CTstCBotView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
///////////////////////////////////
// défini la fonction "show()"
// --------------------------------
CBotProgram::AddFunction("show", rShow, cShow);
CBotProgram::AddFunction("err", rShow, cErr);
CBotProgram::AddFunction("print", rPrint, cPrint);
CBotProgram::AddFunction("println", rPrintLn, cPrint);
///////////////////////////////////
// définie la classe globale CPoint
// --------------------------------
CBotClass* m_pClassPoint;
m_pClassPoint = new CBotClass("CPoint", NULL);
// ajoute le composant ".x"
m_pClassPoint->AddItem("x", CBotTypFloat);
// ajoute le composant ".y"
m_pClassPoint->AddItem("y", CBotTypFloat);
// ajoute le constructeur pour cette classe
m_pClassPoint->AddFunction("CPoint", rCPoint, cCPoint);
// ajoute la méthode Opposé
m_pClassPoint->AddFunction("Opposé", rOppose, cOppose);
//////////////////////////////////////////////////////////////////
// compile un bout de programme pour voir s'il est bien accessible
// depuis un autre "module"
CBotProgram* p = new CBotProgram;
CBotStringArray Liste;
p->Compile(" public void MonProgram( ) { show (\"mon programme\") ;}", Liste );
// l'objet n'est pas détruit et plus référencé
// je sais c'est pas bien
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CTstCBotApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CTstCBotApp commands

View File

@ -1,180 +0,0 @@
# Microsoft Developer Studio Project File - Name="TstCBot" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=TstCBot - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "TstCBot.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "TstCBot.mak" CFG="TstCBot - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "TstCBot - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "TstCBot - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "TstCBot - Win32 Release"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /FR /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "NDEBUG" /d "_AFXDLL"
# ADD RSC /l 0x40c /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
# ADD LINK32 /nologo /subsystem:windows /machine:I386
!ELSEIF "$(CFG)" == "TstCBot - Win32 Debug"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /FR /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "_DEBUG" /d "_AFXDLL"
# ADD RSC /l 0x40c /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "TstCBot - Win32 Release"
# Name "TstCBot - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\BotConsoleDlg.cpp
# End Source File
# Begin Source File
SOURCE=.\MainFrm.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"stdafx.h"
# End Source File
# Begin Source File
SOURCE=.\TstCBot.cpp
# End Source File
# Begin Source File
SOURCE=.\TstCBot.rc
!IF "$(CFG)" == "TstCBot - Win32 Release"
!ELSEIF "$(CFG)" == "TstCBot - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\TstCBotDoc.cpp
# End Source File
# Begin Source File
SOURCE=.\TstCBotView.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\BotConsoleDlg.h
# End Source File
# Begin Source File
SOURCE=.\MainFrm.h
# End Source File
# Begin Source File
SOURCE=.\Resource.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# Begin Source File
SOURCE=.\TstCBot.h
# End Source File
# Begin Source File
SOURCE=.\TstCBotDoc.h
# End Source File
# Begin Source File
SOURCE=.\TstCBotView.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\res\TstCBot.ico
# End Source File
# Begin Source File
SOURCE=.\res\TstCBot.rc2
# End Source File
# Begin Source File
SOURCE=.\res\TstCBotDoc.ico
# End Source File
# End Group
# Begin Source File
SOURCE=.\ReadMe.txt
# End Source File
# End Target
# End Project

View File

@ -1,62 +0,0 @@
// TstCBot.h : main header file for the TSTCBOT application
//
#if !defined(AFX_TSTCBOT_H__70B37568_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)
#define AFX_TSTCBOT_H__70B37568_5DFD_11D4_A15E_00E0189013DF__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
#include "..\CBotDll.h"
class CMyThread;
/////////////////////////////////////////////////////////////////////////////
// CTstCBotApp:
// See TstCBot.cpp for the implementation of this class
//
class CTstCBotApp : public CWinApp
{
public:
CTstCBotApp();
CMyThread* m_pThread;
CWnd* m_pView;
CEdit* m_pConsole;
CBotStringArray m_Liste;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTstCBotApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CTstCBotApp)
afx_msg void OnAppAbout();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TSTCBOT_H__70B37568_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)
#define WM_STARTPROG WM_APP + 0
#define WM_ENDPROG WM_APP + 1

View File

@ -1,471 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// French (France) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
#ifdef _WIN32
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 12, 1\r\n"
"#pragma code_page(1252)\r\n"
"#endif\r\n"
"#include ""res\\TstCBot.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""l.fra\\afxres.rc"" // Standard components\r\n"
"#endif\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "res\\TstCBot.ico"
IDR_TSTCBOTYPE ICON DISCARDABLE "res\\TstCBotDoc.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MAINFRAME MENU PRELOAD DISCARDABLE
BEGIN
POPUP "&Fichier"
BEGIN
MENUITEM "&Nouveau\tCtrl+N", ID_FILE_NEW
MENUITEM "&Ouvrir...\tCtrl+O", ID_FILE_OPEN
MENUITEM "&Enregistrer\tCtrl+S", ID_FILE_SAVE
MENUITEM "En&registrer sous...", ID_FILE_SAVE_AS
MENUITEM SEPARATOR
MENUITEM "Fichier récent", ID_FILE_MRU_FILE1, GRAYED
MENUITEM SEPARATOR
MENUITEM "&Quitter", ID_APP_EXIT
END
POPUP "&Edition"
BEGIN
MENUITEM "&Annuler\tCtrl+Z", ID_EDIT_UNDO
MENUITEM SEPARATOR
MENUITEM "&Couper\tCtrl+X", ID_EDIT_CUT
MENUITEM "&Copier\tCtrl+C", ID_EDIT_COPY
MENUITEM "C&oller\tCtrl+V", ID_EDIT_PASTE
END
POPUP "&Affichage"
BEGIN
MENUITEM "Barre d'é&tat", ID_VIEW_STATUS_BAR
END
POPUP "&Tests"
BEGIN
MENUITEM "&Compile\tAlt+C", ID_CP1
MENUITEM "&Execute\tAlt+V", ID_EXE
END
POPUP "&?"
BEGIN
MENUITEM "&A propos de TstCBot...", ID_APP_ABOUT
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
BEGIN
"C", ID_CP1, VIRTKEY, ALT, NOINVERT
"N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT
"O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT
"S", ID_FILE_SAVE, VIRTKEY, CONTROL, NOINVERT
"V", ID_EXE, VIRTKEY, ALT, NOINVERT
VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT
VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT
VK_F5, ID_EXE, VIRTKEY, NOINVERT
VK_F7, ID_CP1, VIRTKEY, NOINVERT
"X", ID_EXE, VIRTKEY, ALT, NOINVERT
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 217, 55
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "A propos de TstCBot"
FONT 8, "MS Sans Serif"
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
LTEXT "TstCBot version 1.0",IDC_STATIC,40,10,119,8,SS_NOPREFIX
LTEXT "Copyright (C) 1900",IDC_STATIC,40,25,119,8
DEFPUSHBUTTON "OK",IDOK,178,7,32,14,WS_GROUP
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040C04B0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "Application MFC TstCBot\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "TstCBot\0"
VALUE "LegalCopyright", "Copyright (C) 1900\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "TstCBot.EXE\0"
VALUE "ProductName", "Application TstCBot\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Traduction", 0x40c, 1200
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_ABOUTBOX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 210
TOPMARGIN, 7
BOTTOMMARGIN, 48
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
IDR_MAINFRAME "TstCBot\n\nTstCBo\n\n\nTstCBot.Document\nTstCBo Document"
END
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
AFX_IDS_APP_TITLE "TstCBot"
AFX_IDS_IDLEMESSAGE "Prêt"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_INDICATOR_EXT "EXT"
ID_INDICATOR_CAPS "MAJ"
ID_INDICATOR_NUM "NUM"
ID_INDICATOR_SCRL "DEF"
ID_INDICATOR_OVR "ECR"
ID_INDICATOR_REC "ENR"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_FILE_NEW "Crée un nouveau document\nNouveau"
ID_FILE_OPEN "Ouvre un document existant\nOuvrir"
ID_FILE_CLOSE "Ferme le document actif\nFermer"
ID_FILE_SAVE "Enregistre le document actif\nEnregistrer"
ID_FILE_SAVE_AS "Enregistre le document actif sous un nouveau nom\nEnregistrer sous"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_APP_ABOUT "Affiche des informations sur le programme, le numéro de version et le copyright\nA propos de"
ID_APP_EXIT "Ferme l'application ; propose d'enregistrer les documents\nQuitter"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_FILE_MRU_FILE1 "Ouvre ce document"
ID_FILE_MRU_FILE2 "Ouvre ce document"
ID_FILE_MRU_FILE3 "Ouvre ce document"
ID_FILE_MRU_FILE4 "Ouvre ce document"
ID_FILE_MRU_FILE5 "Ouvre ce document"
ID_FILE_MRU_FILE6 "Ouvre ce document"
ID_FILE_MRU_FILE7 "Ouvre ce document"
ID_FILE_MRU_FILE8 "Ouvre ce document"
ID_FILE_MRU_FILE9 "Ouvre ce document"
ID_FILE_MRU_FILE10 "Ouvre ce document"
ID_FILE_MRU_FILE11 "Ouvre ce document"
ID_FILE_MRU_FILE12 "Ouvre ce document"
ID_FILE_MRU_FILE13 "Ouvre ce document"
ID_FILE_MRU_FILE14 "Ouvre ce document"
ID_FILE_MRU_FILE15 "Ouvre ce document"
ID_FILE_MRU_FILE16 "Ouvre ce document"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_NEXT_PANE "Passe au volet de fenêtre suivant\nVolet suivant"
ID_PREV_PANE "Revient au volet précédent\nVolet précédent"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_WINDOW_SPLIT "Fractionne la fenêtre active en deux volets\nFractionner"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_EDIT_CLEAR "Efface la sélection\nEffacer"
ID_EDIT_CLEAR_ALL "Efface tout\nEffacer tout"
ID_EDIT_COPY "Copie la sélection et la place dans le Presse-papiers\nCopier"
ID_EDIT_CUT "Supprime la sélection et la place dans le Presse-papiers\nCopier"
ID_EDIT_FIND "Recherche le texte spécifié\nRechercher"
ID_EDIT_PASTE "Insère le contenu du Presse-papiers\nColler"
ID_EDIT_REPEAT "Répète la dernière action\nRépéter"
ID_EDIT_REPLACE "Remplace le texte spécifique par un texte différent\nRemplacer"
ID_EDIT_SELECT_ALL "Sélectionne le document entier\nSélectionner tout"
ID_EDIT_UNDO "Annule la dernière action\nAnnuler"
ID_EDIT_REDO "Rétablit l'action précédemment annulée\nRétablir"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_VIEW_STATUS_BAR "Affiche ou masque la barre d'état\nBarre d'état"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_SCSIZE "Change la taille de la fenêtre"
AFX_IDS_SCMOVE "Change la position de la fenêtre"
AFX_IDS_SCMINIMIZE "Réduit la fenêtre en icône"
AFX_IDS_SCMAXIMIZE "Agrandit la fenêtre au format de l'écran"
AFX_IDS_SCNEXTWINDOW "Passe à la fenêtre de document suivante"
AFX_IDS_SCPREVWINDOW "Passe à la fenêtre de document précédente"
AFX_IDS_SCCLOSE "Ferme la fenêtre active et propose l'enregistrement des documents"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_SCRESTORE "Restaure la fenêtre à sa taille d'origine"
AFX_IDS_SCTASKLIST "Active la liste des tâches"
END
STRINGTABLE DISCARDABLE
BEGIN
TX_TYPENAMES "les différents types"
1001 "Byte"
1002 "Short"
1003 "Char"
1004 "Int"
1005 "Long"
1006 "Real"
1007 "Double"
END
STRINGTABLE DISCARDABLE
BEGIN
1008 "Boolean"
1009 "Class"
1010 "String"
END
STRINGTABLE DISCARDABLE
BEGIN
TX_OPENPAR "Il manque une parenthèse ouvrante."
TX_CLOSEPAR "Il manque une parenthèse fermante."
TX_NOTBOOL "L'expression doit être un boolean."
TX_UNDEFVAR "Variable non déclarée."
TX_BADLEFT "Assignation impossible."
TX_ENDOF "Instruction non terminée."
TX_OUTCASE "Instruction ""case"" hors d'un bloc ""switch""."
TX_NOTERM "Instructions après la fin."
END
STRINGTABLE DISCARDABLE
BEGIN
TX_CLOSEBLK "Il manque la fin du bloc."
TX_ELSEWITHOUTIF "Instruction ""else"" sans ""if"" correspondant."
TX_OPENBLK "Début d'un bloc attendu."
TX_BADTYPE "Mauvais type de résultat pour l'assignation."
TX_REDEFVAR "Redéfinition d'une variable."
TX_BAD2TYPE "Les deux opérandes ne sont pas de types compatibles."
TX_UNDEFCALL "Routine inconnue."
TX_MISDOTS "Séparateur "" : "" attendu."
TX_WHILE "Manque le mot ""while""."
TX_BREAK "Instruction ""break"" en dehors d'une boucle."
TX_LABEL "Un label ne peut se placer que devant un ""for"", un ""while"", un ""do"" ou un ""switch""."
TX_NOLABEL "Cette étiquette n'existe pas"
TX_NOCASE "Manque une instruction ""case""."
TX_BADNUM "Un nombre est attendu."
TX_VOID "Paramètre void."
TX_NOTYP "Déclaration de type attendu"
END
STRINGTABLE DISCARDABLE
BEGIN
TX_DIVZERO "Division par zéro."
TX_NOTINIT "Variable non initialisée."
TX_BADTHROW "Valeur négative refusée pour ""throw""."
TX_NORETVAL "La fonction n'a pas retourné de résultat"
TX_NORUN "Pas de fonction en exécution"
TX_NOCALL "Appel d'une fonction inexistante"
END
STRINGTABLE DISCARDABLE
BEGIN
TX_NOVAR "Nom d'une variable attendu"
TX_NOFONC "Nom de la fonction attendu."
TX_OVERPARAM "Trop de paramètres"
TX_REDEF "Cette fonction existe déjà."
TX_LOWPARAM "Pas assez de paramètres"
TX_BADPARAM "Aucune fonction de ce nom n'accepte ce(s) type(s) de paramètre(s)"
TX_NUMPARAM "Aucune fonction de ce nom n'accepte ce nombre de paramètres"
TX_NOITEM "Cet élément n'exite pas dans cette classe."
TX_DOT "L'objet n'est pas une instance d'une classe."
TX_NOCONST "Il n'y a pas de constructeur approprié."
TX_REDEFCLASS "Cette classe existe déjà."
END
#endif // French (France) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// French (Switzerland) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRS)
#ifdef _WIN32
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH_SWISS
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_CONSOLE DIALOG DISCARDABLE 0, 0, 401, 210
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "CBot Console"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Commande :",IDC_STATIC,7,177,40,8
EDITTEXT IDC_EDIT2,7,189,329,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "Exécute",IDOK,344,189,50,14
EDITTEXT IDC_EDIT1,7,7,387,167,ES_MULTILINE | ES_READONLY |
ES_WANTRETURN | WS_VSCROLL
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_CONSOLE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 394
TOPMARGIN, 7
BOTTOMMARGIN, 203
END
END
#endif // APSTUDIO_INVOKED
#endif // French (Switzerland) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
#ifdef _WIN32
LANGUAGE 12, 1
#pragma code_page(1252)
#endif
#include "res\TstCBot.rc2" // non-Microsoft Visual C++ edited resources
#include "l.fra\afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -1,83 +0,0 @@
// TstCBotDoc.cpp : implementation of the CTstCBotDoc class
//
#include "stdafx.h"
#include "TstCBot.h"
#include "TstCBotDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTstCBotDoc
IMPLEMENT_DYNCREATE(CTstCBotDoc, CDocument)
BEGIN_MESSAGE_MAP(CTstCBotDoc, CDocument)
//{{AFX_MSG_MAP(CTstCBotDoc)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTstCBotDoc construction/destruction
CTstCBotDoc::CTstCBotDoc()
{
// TODO: add one-time construction code here
}
CTstCBotDoc::~CTstCBotDoc()
{
}
BOOL CTstCBotDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CTstCBotDoc serialization
void CTstCBotDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CTstCBotDoc diagnostics
#ifdef _DEBUG
void CTstCBotDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CTstCBotDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CTstCBotDoc commands

View File

@ -1,55 +0,0 @@
// TstCBotDoc.h : interface of the CTstCBotDoc class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_TSTCBOTDOC_H__70B3756E_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)
#define AFX_TSTCBOTDOC_H__70B3756E_5DFD_11D4_A15E_00E0189013DF__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
class CTstCBotDoc : public CDocument
{
protected: // create from serialization only
CTstCBotDoc();
DECLARE_DYNCREATE(CTstCBotDoc)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTstCBotDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CTstCBotDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CTstCBotDoc)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TSTCBOTDOC_H__70B3756E_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)

View File

@ -1,291 +0,0 @@
// TstCBotView.cpp : implementation of the CTstCBotView class
//
#include "stdafx.h"
#include "TstCBot.h"
#include "TstCBotDoc.h"
#include "TstCBotView.h"
#include "BotConsoleDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTstCBotView
IMPLEMENT_DYNCREATE(CTstCBotView, CView)
BEGIN_MESSAGE_MAP(CTstCBotView, CView)
//{{AFX_MSG_MAP(CTstCBotView)
ON_WM_SIZE()
ON_COMMAND(ID_CP1, OnCp1)
ON_COMMAND(ID_EXE, OnExe)
ON_COMMAND(ID_FILE_SAVE, OnFileSave)
ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTstCBotView construction/destruction
CTstCBotView::CTstCBotView()
{
// TODO: add construction code here
m_pEdit = NULL;
m_pProg = NULL;
}
CTstCBotView::~CTstCBotView()
{
}
BOOL CTstCBotView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
void CTstCBotView::OnActivateView( BOOL bActivate, CView* pActivateView, CView* pDeactiveView )
{
if ( m_pEdit == NULL)
{
m_pEdit = new CEdit();
CRect rect;
GetClientRect( rect );
m_pEdit->Create( WS_VISIBLE|WS_BORDER|WS_TABSTOP|ES_MULTILINE|ES_WANTRETURN|ES_NOHIDESEL|ES_AUTOVSCROLL,
rect, this, IDC_EDIT1 );
m_pEdit->SetTabStops(12);
LoadEdition("CBotTest.txt");
m_pEdit->SetFocus();
}
}
/////////////////////////////////////////////////////////////////////////////
// CTstCBotView drawing
void CTstCBotView::OnDraw(CDC* pDC)
{
CTstCBotDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CTstCBotView diagnostics
#ifdef _DEBUG
void CTstCBotView::AssertValid() const
{
CView::AssertValid();
}
void CTstCBotView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CTstCBotDoc* CTstCBotView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTstCBotDoc)));
return (CTstCBotDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CTstCBotView message handlers
void CTstCBotView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
if ( m_pEdit != NULL )
{
CRect rect;
GetClientRect( rect );
m_pEdit->MoveWindow( rect );
m_pEdit->SetFocus();
}
}
void CTstCBotView::SaveEdition(const char* filename)
{
CString program;
m_pEdit->GetWindowText(program);
FILE* pf = fopen(filename, "wb");
if (pf==NULL) return;
fputs (program, pf);
fclose(pf);
}
void CTstCBotView::LoadEdition(const char* filename)
{
CString program("{ int x = 10000; while (x > 0) x = x-1; }");
FILE* pf = fopen(filename, "r");
if (pf!=NULL)
{
char buffer[10000];
program.Empty();
while (NULL != fgets (buffer, 100000, pf))
{
program += buffer;
program = program.Left(program.GetLength()-1) + "\r\n";
}
fclose(pf);
}
m_pEdit->SetWindowText(program);
}
// compile le programme
#include <stdio.h>
void CTstCBotView::OnCp1()
{
CString program;
SaveEdition("CBotTest.txt");
m_pEdit->GetWindowText(program);
CString TextError;
int code, start, end;
if ( m_pProg == NULL ) m_pProg = new CBotProgram();
CTstCBotApp* pApp = (CTstCBotApp*)AfxGetApp();
if (m_pProg->Compile(program, pApp->m_Liste))
{
CString done = "Compilation sans erreur.\nLes fonctions suivantes sont externes:\n";
for ( int i = 0; i < pApp->m_Liste.RetSize(); i++)
{
done += CString(pApp->m_Liste[i]) + "\n";
}
AfxMessageBox( done );
}
else
{
m_pProg->GetError(code, start, end);
delete m_pProg;
m_pProg = NULL;
m_pEdit->SetSel( start, end );
m_pEdit->SetFocus(); // met en évidence la partie avec problème
TextError.LoadString( code );
if (TextError.IsEmpty())
{
char buf[100];
sprintf(buf, "Erreur numéro %d.", code);
TextError = buf;
}
AfxMessageBox( TextError );
}
m_pEdit->SetFocus();
}
//////////////////////////////////////////////////////
void CTstCBotView::OnExe()
{
CTstCBotApp* pApp = (CTstCBotApp*)AfxGetApp();
if( m_pProg == NULL)
{
AfxMessageBox("Pas de programme compilé !");
return;
}
if( pApp->m_Liste.RetSize() == 0 )
{
AfxMessageBox("Aucune fonction marquée \"extern\" !");
return;
}
CBotConsoleDlg dlg;
dlg.DoModal(); // dialogue pour faire la console
if ( dlg.m_code>0 )
{
CString TextError;
m_pEdit->SetSel( dlg.m_start, dlg.m_end );
m_pEdit->SetFocus(); // met en évidence la partie avec problème
TextError.LoadString( dlg.m_code );
if (TextError.IsEmpty())
{
char buf[100];
sprintf(buf, "Erreur numéro %d.", dlg.m_code);
TextError = buf;
}
// AfxMessageBox( TextError );
}
m_pEdit->SetFocus();
return;
}
void CTstCBotView::OnFileSave()
{
// TODO: Add your command handler code here
SaveEdition("CBotTest.txt");
}
void CTstCBotView::OnFileSaveAs()
{
CFileDialog *pDlg;
CString s;
pDlg = new CFileDialog(FALSE, "TXT", NULL,
OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY,
"cboxtest|*.txt", this);
if ( pDlg == NULL ) return;
if ( pDlg->DoModal() == IDOK ) // choix du fichier ...
{
SaveEdition(pDlg->GetPathName());
}
delete pDlg;
}
#if 0
void test()
{
int y,z;
for (;;);
for (x = 0; y = 1; z = 3) int q = 6;
for (int x = 0; int y = 1; int z = 3) int q = 6;
// pour voir
}
#endif

View File

@ -1,81 +0,0 @@
// TstCBotView.h : interface of the CTstCBotView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_TSTCBOTVIEW_H__70B37570_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)
#define AFX_TSTCBOTVIEW_H__70B37570_5DFD_11D4_A15E_00E0189013DF__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
class CBotProgram;
class CBotClass;
class CTstCBotView : public CView
{
protected: // create from serialization only
CTstCBotView();
DECLARE_DYNCREATE(CTstCBotView)
CEdit* m_pEdit; // texte en édition
CWnd* m_pWnd;
CBotProgram* m_pProg; // programme compilé
// Attributes
public:
CTstCBotDoc* GetDocument();
// Operations
public:
void LoadEdition(const char* name);
void SaveEdition(const char* name);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTstCBotView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void OnActivateView( BOOL bActivate, CView* pActivateView, CView* pDeactiveView );
protected:
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CTstCBotView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CTstCBotView)
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnCp1();
afx_msg void OnExe();
afx_msg void OnFileSave();
afx_msg void OnFileSaveAs();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in TstCBotView.cpp
inline CTstCBotDoc* CTstCBotView::GetDocument()
{ return (CTstCBotDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TSTCBOTVIEW_H__70B37570_5DFD_11D4_A15E_00E0189013DF__INCLUDED_)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,13 +0,0 @@
//
// TSTCBOT.RC2 - resources Microsoft Visual C++ does not edit directly
//
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Add manually edited resources here...
/////////////////////////////////////////////////////////////////////////////

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,213 +0,0 @@
// test de l'interpréteur CBot, (c) D. Dumoulin 2000
Int Somme ( Int x, Int y )
{
return x + y;
}
Real Somme ( Real x, Real y )
{
return x + y;
}
void A_Faire()
{
CPoint position; // utilise une classe externe
position.x = 123.5;
position.y = -45.1;
show ( position );
}
/* Les nouveautés sont les suivantes
__________________________________________________
On peut définir des fonctions, avec la syntaxe habituelle au C
void MaFonction( Int x, Real y ) { ... }
Les caractéristiques sont pour l'instant les suivantes:
- ce programme TstCBot exécute la dernière fonction définie
- on peut définir deux fonctions du même nom,
si la liste de paramètres est différente.
Par exemple
Int Somme( Int x, Int y )
Real Somme( Real x, Real y );
Note: si la seconde n'existait pas, Somme ( 1.3, 4.8 )
serait fait sur les nombres entier 1 + 4
La priorité est donnée à la routine qui ne pert pas
de bits dans la conversion des paramètres.
- il n'y a pas d'erreur de compilation si une routine
ne retourne pas de valeur alors qu'elle devrait,
par contre il y a une erreur "correcte" à l'exécution
- il est possible d'utiliser une fonction qui est définie
plus bas dans le programme.
__________________________________________________
Tous les blocs d'instructions existent maintenant, à savoir
label :
while (condition) { instructions; break label; continue label; }
label :
do { instructions; break label; continue label; } while (condition)
label:
for (initial; condition; incrément) { instructions; break; continue }
switch ( valeur ) { case 1: instructions; case 2: break ; }
try {instructions; throw exception; } catch (exception) {instructions;}
catch (testlogique) {instructions;}
finally {instructions;}
// le bloc finally est exécuter dans tous les cas
// qu'il y ait eu exception ou non, et aussi en cas de break, continue ou return
__________________________________________________
Les "exceptions" sont juste des numéros (31 bits)
6000 = division par zéro
6001 = variable non initialisée
6002 = valeur négative pour un throw
6003 = la fonction n'a pas retourné de valeur
les autres numéros sont à disposition
(COLOBOT aura surement des numéros d'exception propre)
l'association d'un mot clef pour ces exceptions est à venir.
__________________________________________________
L'interpréteur a été un peu optimiser, une boucle de un millon de décrément
ne prend plus que
*/
void Test ()
{ // début du bloc d'instructions
Int z = 1000000;
while ( z>0 ) z--;
return;
{
// test la préséance pour les assignations
Int a = 9;
a += (a = 3);
if ( a != 12 ) 1/0; // le résultat correct est 12
Int b = 9;
b = b + (b = 3);
if (b != 12) 1/0; // même chose
// la fonction show est une fonction externe
// définie par TstCBot
// elle peut prendre un nombre quelconque de paramètres
show ( a, b );
}
{
// petit test sur les chaînes
String x = "ch." ;
String y ;
x += y = x + " de la brume.";
// concaténation de chaînes, accepte des autres types
String s = 1 + 2 + " test " + 3 + 4 ;
show( x, y, s );
// les tests sur les chaînes ne sont pas standard en Java
// mais c'est si pratique :
if ( s != "3 test 34" ) 1/0; // le résultat correct est "3 test 34"
// car 1+2 est évalué en premier entre 2 nombres
// et ensuite on additionne des chaînes "3" "4"
}
{
// teste toutes les opérations avec les entiers (32 bits)
Int a = 4;
Int b = 4;
Int c = a++ * --b; // post incrément, pré décrément
if ( c != 12 ) 1/0;
c = ++a * b--; // pré incrément, post décrément
if ( c!=18 ) 1/0;
a = a+b-a*b/a%3; // 6 + 2 - ( 6 * 2 / 6 % 3 ) -> 6
if ( a != 6 ) 1/0;
a += 2; a-=1; a*=3; a/=4; a%=3; // (6+2 -1) *3 /4 modulo 3 = 21 / 4 modulo 3 = 2
if ( a!= 2) 0/0;
if (-5 << 3 != -40) 0/0; // shift à gauche
if ( -5 >> 1 != -3) 0/0; // shift arithmétique à droite 11111011 -> 11111101 = -3
if ( -5 >>> 1 != 0x3ffffffd) 0/0; // shift non signé à droite
a = -10; // fait la même chose en assignation
a <<= 1; // -20
a >>= 2; // -5
a >>>= 1; // pert le signe
if ( a != 0x3ffffffd) 0/0; //
Int x = 5/3; // division d'entiers
if ( x != 1 ) 0/0;
Int xx = 5.0/3.0; // division de réels, assigné à un entier
if ( xx != 1 ) 0/0;
Int y = 0xF0035678;
if ( ~y != 0x0FFCA987 ) 0/0; // NOT bit à bit
if ( (0x3456 ^ 0x54f0) != 0x60A6) // XOR bit à bit
0/0;
if ( (0x23 | 0x83) != 0xA3 ) 0/0; // OR bit à bit
if ( (0x23 & 0x83) != 0x03 ) 0/0; // AND bit à bit
Int z = 0x0123;
z |= 0x8010; if ( z != 0x8133) 0/0;
z &= 0xF018; if ( z != 0x8010) 0/0;
z ^= 0xFF17; if ( z != 0x7F07) 0/0;
}
{
// test pour les booléens
Boolean a, b= true, c = false;
a = b | c & b;
if ( a != b ) 0/0;
if ( !a ) 0/0;
if ( b ^ a ) 0/0; // XOR
if ( true || 0/0<1 ) {};
if ( false && 0/0<1) {};
// a ? "vrai" : "faux";
}
{
// petit test sur les nombres réels
Real x = 1. / 3, y = 0;
if ( 3 * x != 1 ) x = x / y; // provoque une division par zéro
else y = 1.123;
}
// test de durée
// attention, le programme de test ne stoppe qu'à la fin d'exécution
// bien que la boucle est interrompue plusieures fois
// la boucle est plus rapide si elle est au début du programme !
{
Int z = 10000;
while ( z > 0 ) z = z - 1;
}
}
void t()
{
A_Faire();
show ( Somme ( 1, 2 ) );
show ( Somme ( 1., 2 ) );
show ( Somme ( 4.5, 2.7 ) );
}

View File

@ -1,43 +0,0 @@
// test de l'interpréteur CBot, (c) D. Dumoulin 2000
// pour l'instant, seule les primitives suivantes sont implémentées
// { ... ; ... ; ... } un bloc d'instructions
// int x, y = 12, z; // déclaration de nombre entier
// float a, b= 2/3, c=b+1; // déclaration de nombres réels
// boolean tst = true; // déclaration d'un booléen
// String x = "hello"; // déclaration d'une chaînes
// z = x = x * y / ( z + 1 - x ); // assignation en chaîne et les 4 opérations
// while ( x >= 0 ) x = x - 1; // boucle while, et test > >= < <= == !=
// if ( x < y ) x = x + 1; // test si
// else y = y + 1; // sinon
/* et les opérations suivantes:
+ plus unaire x = +y;
- moins unaire x = -y;
|| OU logique
&& ET logique
! NOT logique
| OU bit à bit
& ET bit à bit
^ XOR bit à bit
~ NON bit à bit
// les commentaires sont acceptés
/* y compris les commentaires
sur plusieures lignes */
{
String str ;
str = "abc" ;
show (str) ;
show( str = str + "+++" , ) ;
}

View File

@ -2,7 +2,7 @@ extern public void x()
{
float a= 1, b = 2;
a = b * ( 2 + 2 );
// print (a);
print (a);
a += 4;
// print (a);
}
print (a);
}

Some files were not shown because too many files have changed in this diff Show More