Changed GivAttrName() to GetAttrName()
parent
7b03a6a2ac
commit
a9186d1960
File diff suppressed because it is too large
Load Diff
144
src/CBot/CBot.h
144
src/CBot/CBot.h
|
@ -105,18 +105,18 @@ public:
|
||||||
bool StackOver();
|
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] start beginning of the stack
|
||||||
* \param [out] end end of stack
|
* \param [out] end end of stack
|
||||||
* \return error number
|
* \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
|
* \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
|
* \brief Reset Reset error at and set user
|
||||||
|
@ -131,18 +131,18 @@ public:
|
||||||
void SetType(CBotTypResult& type);
|
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).
|
* \param [in] mode Used when getting class type (1 gives pointer, 2 gives intrinsic).
|
||||||
* \return Type number.
|
* \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).
|
* \param [in] mode Used when getting class type (1 gives pointer, 2 gives intrinsic).
|
||||||
* \return Type of an element.
|
* \return Type of an element.
|
||||||
*/
|
*/
|
||||||
CBotTypResult GivTypResult(int mode = 0);
|
CBotTypResult GetTypResult(int mode = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Adds a local variable.
|
* \brief Adds a local variable.
|
||||||
|
@ -215,18 +215,18 @@ public:
|
||||||
bool IsOk();
|
bool IsOk();
|
||||||
|
|
||||||
bool SetState(int n, int lim = -10); // select a state
|
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 IncState(int lim = -10); // passes to the next state
|
||||||
bool IfStep(); // do step by step
|
bool IfStep(); // do step by step
|
||||||
bool Execute();
|
bool Execute();
|
||||||
|
|
||||||
void SetVar( CBotVar* var );
|
void SetVar( CBotVar* var );
|
||||||
void SetCopyVar( CBotVar* var );
|
void SetCopyVar( CBotVar* var );
|
||||||
CBotVar* GivVar();
|
CBotVar* GetVar();
|
||||||
CBotVar* GivCopyVar();
|
CBotVar* GetCopyVar();
|
||||||
CBotVar* GivPtVar();
|
CBotVar* GetPtVar();
|
||||||
bool GivRetVar(bool bRet);
|
bool GetRetVar(bool bRet);
|
||||||
long GivVal();
|
long GetVal();
|
||||||
|
|
||||||
void SetStartError(int pos);
|
void SetStartError(int pos);
|
||||||
void SetError(int n, CBotToken* token = NULL);
|
void SetError(int n, CBotToken* token = NULL);
|
||||||
|
@ -235,9 +235,9 @@ public:
|
||||||
void SetBreak(int val, const char* name);
|
void SetBreak(int val, const char* name);
|
||||||
|
|
||||||
void SetBotCall(CBotProgram* p);
|
void SetBotCall(CBotProgram* p);
|
||||||
CBotProgram* GivBotCall(bool bFirst = false);
|
CBotProgram* GetBotCall(bool bFirst = false);
|
||||||
void* GivPUser();
|
void* GetPUser();
|
||||||
bool GivBlock();
|
bool GetBlock();
|
||||||
|
|
||||||
|
|
||||||
bool ExecuteCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotTypResult& rettype);
|
bool ExecuteCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotTypResult& rettype);
|
||||||
|
@ -250,7 +250,7 @@ public:
|
||||||
void SetTimer(int n);
|
void SetTimer(int n);
|
||||||
|
|
||||||
void GetRunPos(const char* &FunctionName, int &start, int &end);
|
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;
|
int m_temp;
|
||||||
|
|
||||||
|
@ -301,12 +301,12 @@ inline bool CBotStack::IsOk()
|
||||||
return (m_error == 0);
|
return (m_error == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int CBotStack::GivState()
|
inline int CBotStack::GetState()
|
||||||
{
|
{
|
||||||
return m_state;
|
return m_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int CBotStack::GivError()
|
inline int CBotStack::GetError()
|
||||||
{
|
{
|
||||||
return m_error;
|
return m_error;
|
||||||
}
|
}
|
||||||
|
@ -343,14 +343,14 @@ public:
|
||||||
~CBotCStack();
|
~CBotCStack();
|
||||||
|
|
||||||
bool IsOk();
|
bool IsOk();
|
||||||
int GivError();
|
int GetError();
|
||||||
int GivError(int& start, int& end);
|
int GetError(int& start, int& end);
|
||||||
// gives error number
|
// gives error number
|
||||||
|
|
||||||
void SetType(CBotTypResult& type);// determines the type
|
void SetType(CBotTypResult& type);// determines the type
|
||||||
CBotTypResult GivTypResult(int mode = 0); // gives the type of value on the stack
|
CBotTypResult GetTypResult(int mode = 0); // gives the type of value on the stack
|
||||||
int GivType(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* GivClass(); // gives the class of the value on the stack
|
CBotClass* GetClass(); // gives the class of the value on the stack
|
||||||
|
|
||||||
void AddVar(CBotVar* p); // adds a local variable
|
void AddVar(CBotVar* p); // adds a local variable
|
||||||
CBotVar* FindVar(CBotToken* &p); // finds a variable
|
CBotVar* FindVar(CBotToken* &p); // finds a variable
|
||||||
|
@ -364,7 +364,7 @@ public:
|
||||||
|
|
||||||
void SetVar( CBotVar* var );
|
void SetVar( CBotVar* var );
|
||||||
void SetCopyVar( CBotVar* var );
|
void SetCopyVar( CBotVar* var );
|
||||||
CBotVar* GivVar();
|
CBotVar* GetVar();
|
||||||
|
|
||||||
void SetStartError(int pos);
|
void SetStartError(int pos);
|
||||||
void SetError(int n, int pos);
|
void SetError(int n, int pos);
|
||||||
|
@ -372,11 +372,11 @@ public:
|
||||||
void ResetError(int n, int start, int end);
|
void ResetError(int n, int start, int end);
|
||||||
|
|
||||||
void SetRetType(CBotTypResult& type);
|
void SetRetType(CBotTypResult& type);
|
||||||
CBotTypResult GivRetType();
|
CBotTypResult GetRetType();
|
||||||
|
|
||||||
// void SetBotCall(CBotFunction* &pFunc);
|
// void SetBotCall(CBotFunction* &pFunc);
|
||||||
void SetBotCall(CBotProgram* p);
|
void SetBotCall(CBotProgram* p);
|
||||||
CBotProgram* GivBotCall();
|
CBotProgram* GetBotCall();
|
||||||
CBotTypResult CompileCall(CBotToken* &p, CBotVar** ppVars, long& nIdent);
|
CBotTypResult CompileCall(CBotToken* &p, CBotVar** ppVars, long& nIdent);
|
||||||
bool CheckCall(CBotToken* &pToken, CBotDefParam* pParam);
|
bool CheckCall(CBotToken* &pToken, CBotDefParam* pParam);
|
||||||
|
|
||||||
|
@ -454,15 +454,15 @@ public:
|
||||||
bool CompCase(CBotStack* &pj, int val);
|
bool CompCase(CBotStack* &pj, int val);
|
||||||
|
|
||||||
void SetToken(CBotToken* p);
|
void SetToken(CBotToken* p);
|
||||||
int GivTokenType();
|
int GetTokenType();
|
||||||
CBotToken* GivToken();
|
CBotToken* GetToken();
|
||||||
|
|
||||||
void AddNext(CBotInstr* n);
|
void AddNext(CBotInstr* n);
|
||||||
CBotInstr* GivNext();
|
CBotInstr* GetNext();
|
||||||
void AddNext3(CBotInstr* n);
|
void AddNext3(CBotInstr* n);
|
||||||
CBotInstr* GivNext3();
|
CBotInstr* GetNext3();
|
||||||
void AddNext3b(CBotInstr* n);
|
void AddNext3b(CBotInstr* n);
|
||||||
CBotInstr* GivNext3b();
|
CBotInstr* GetNext3b();
|
||||||
|
|
||||||
static
|
static
|
||||||
void IncLvl(CBotString& label);
|
void IncLvl(CBotString& label);
|
||||||
|
@ -1263,9 +1263,9 @@ public:
|
||||||
|
|
||||||
void SetValInt(int val, const char* s = NULL);
|
void SetValInt(int val, const char* s = NULL);
|
||||||
void SetValFloat(float val);
|
void SetValFloat(float val);
|
||||||
int GivValInt();
|
int GetValInt();
|
||||||
float GivValFloat();
|
float GetValFloat();
|
||||||
CBotString GivValString();
|
CBotString GetValString();
|
||||||
|
|
||||||
void Copy(CBotVar* pSrc, bool bName=true);
|
void Copy(CBotVar* pSrc, bool bName=true);
|
||||||
|
|
||||||
|
@ -1314,9 +1314,9 @@ public:
|
||||||
|
|
||||||
void SetValInt(int val, const char* s = NULL);
|
void SetValInt(int val, const char* s = NULL);
|
||||||
void SetValFloat(float val);
|
void SetValFloat(float val);
|
||||||
int GivValInt();
|
int GetValInt();
|
||||||
float GivValFloat();
|
float GetValFloat();
|
||||||
CBotString GivValString();
|
CBotString GetValString();
|
||||||
|
|
||||||
void Copy(CBotVar* pSrc, bool bName=true);
|
void Copy(CBotVar* pSrc, bool bName=true);
|
||||||
|
|
||||||
|
@ -1354,7 +1354,7 @@ public:
|
||||||
// ~CBotVarString();
|
// ~CBotVarString();
|
||||||
|
|
||||||
void SetValString(const char* p);
|
void SetValString(const char* p);
|
||||||
CBotString GivValString();
|
CBotString GetValString();
|
||||||
|
|
||||||
void Copy(CBotVar* pSrc, bool bName=true);
|
void Copy(CBotVar* pSrc, bool bName=true);
|
||||||
|
|
||||||
|
@ -1382,9 +1382,9 @@ public:
|
||||||
|
|
||||||
void SetValInt(int val, const char* s = NULL);
|
void SetValInt(int val, const char* s = NULL);
|
||||||
void SetValFloat(float val);
|
void SetValFloat(float val);
|
||||||
int GivValInt();
|
int GetValInt();
|
||||||
float GivValFloat();
|
float GetValFloat();
|
||||||
CBotString GivValString();
|
CBotString GetValString();
|
||||||
|
|
||||||
void Copy(CBotVar* pSrc, bool bName=true);
|
void Copy(CBotVar* pSrc, bool bName=true);
|
||||||
|
|
||||||
|
@ -1426,14 +1426,14 @@ public:
|
||||||
|
|
||||||
void Copy(CBotVar* pSrc, bool bName=true);
|
void Copy(CBotVar* pSrc, bool bName=true);
|
||||||
void SetClass(CBotClass* pClass); //, int &nIdent);
|
void SetClass(CBotClass* pClass); //, int &nIdent);
|
||||||
CBotClass* GivClass();
|
CBotClass* GetClass();
|
||||||
CBotVar* GivItem(const char* name); // return an element of a class according to its name (*)
|
CBotVar* GetItem(const char* name); // return an element of a class according to its name (*)
|
||||||
CBotVar* GivItemRef(int nIdent);
|
CBotVar* GetItemRef(int nIdent);
|
||||||
|
|
||||||
CBotVar* GivItem(int n, bool bExtend);
|
CBotVar* GetItem(int n, bool bExtend);
|
||||||
CBotVar* GivItemList();
|
CBotVar* GetItemList();
|
||||||
|
|
||||||
CBotString GivValString();
|
CBotString GetValString();
|
||||||
|
|
||||||
bool Save1State(FILE* pf);
|
bool Save1State(FILE* pf);
|
||||||
void Maj(void* pUser, bool bContinue);
|
void Maj(void* pUser, bool bContinue);
|
||||||
|
@ -1442,7 +1442,7 @@ public:
|
||||||
void DecrementUse(); // a reference to decrementation
|
void DecrementUse(); // a reference to decrementation
|
||||||
|
|
||||||
CBotVarClass*
|
CBotVarClass*
|
||||||
GivPointer();
|
GetPointer();
|
||||||
void SetItemList(CBotVar* pVar);
|
void SetItemList(CBotVar* pVar);
|
||||||
|
|
||||||
void SetIdent(long n);
|
void SetIdent(long n);
|
||||||
|
@ -1450,7 +1450,7 @@ public:
|
||||||
static CBotVarClass* Find(long id);
|
static CBotVarClass* Find(long id);
|
||||||
|
|
||||||
|
|
||||||
// CBotVar* GivMyThis();
|
// CBotVar* GetMyThis();
|
||||||
|
|
||||||
bool Eq(CBotVar* left, CBotVar* right);
|
bool Eq(CBotVar* left, CBotVar* right);
|
||||||
bool Ne(CBotVar* left, CBotVar* right);
|
bool Ne(CBotVar* left, CBotVar* right);
|
||||||
|
@ -1474,18 +1474,18 @@ public:
|
||||||
|
|
||||||
void Copy(CBotVar* pSrc, bool bName=true);
|
void Copy(CBotVar* pSrc, bool bName=true);
|
||||||
void SetClass(CBotClass* pClass);
|
void SetClass(CBotClass* pClass);
|
||||||
CBotClass* GivClass();
|
CBotClass* GetClass();
|
||||||
CBotVar* GivItem(const char* name); // return an element of a class according to its name (*)
|
CBotVar* GetItem(const char* name); // return an element of a class according to its name (*)
|
||||||
CBotVar* GivItemRef(int nIdent);
|
CBotVar* GetItemRef(int nIdent);
|
||||||
CBotVar* GivItemList();
|
CBotVar* GetItemList();
|
||||||
|
|
||||||
CBotString GivValString();
|
CBotString GetValString();
|
||||||
void SetPointer(CBotVar* p);
|
void SetPointer(CBotVar* p);
|
||||||
CBotVarClass*
|
CBotVarClass*
|
||||||
GivPointer();
|
GetPointer();
|
||||||
|
|
||||||
void SetIdent(long n); // associates an identification number (unique)
|
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();
|
void ConstructorSet();
|
||||||
|
|
||||||
bool Save1State(FILE* pf);
|
bool Save1State(FILE* pf);
|
||||||
|
@ -1514,15 +1514,15 @@ public:
|
||||||
|
|
||||||
void SetPointer(CBotVar* p);
|
void SetPointer(CBotVar* p);
|
||||||
CBotVarClass*
|
CBotVarClass*
|
||||||
GivPointer();
|
GetPointer();
|
||||||
|
|
||||||
void Copy(CBotVar* pSrc, bool bName=true);
|
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
|
// enlarged the table if necessary if bExtend
|
||||||
// CBotVar* GivItem(const char* name); // makes a element by literal index
|
// CBotVar* GetItem(const char* name); // makes a element by literal index
|
||||||
CBotVar* GivItemList(); // gives the first item in the list
|
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);
|
bool Save1State(FILE* pf);
|
||||||
};
|
};
|
||||||
|
@ -1544,7 +1544,7 @@ extern bool ReadString(FILE* pf, CBotString& s);
|
||||||
extern bool WriteType(FILE* pf, CBotTypResult type);
|
extern bool WriteType(FILE* pf, CBotTypResult type);
|
||||||
extern bool ReadType(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
|
#if false
|
||||||
extern void DEBUG( const char* text, int val, CBotStack* pile );
|
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);
|
bool RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotStack* pStack);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CBotString GivName();
|
CBotString GetName();
|
||||||
CBotCall* Next();
|
CBotCall* Next();
|
||||||
|
|
||||||
static void SetPUser(void* pUser);
|
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);
|
int DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotVar* &pResult, CBotStack* pStack, CBotToken* pFunc);
|
||||||
|
|
||||||
CBotString GivName();
|
CBotString GetName();
|
||||||
CBotCallMethode* Next();
|
CBotCallMethode* Next();
|
||||||
void AddNext(CBotCallMethode* p);
|
void AddNext(CBotCallMethode* p);
|
||||||
|
|
||||||
|
@ -1655,11 +1655,11 @@ public:
|
||||||
void RestoreState(CBotStack* &pj, bool bMain);
|
void RestoreState(CBotStack* &pj, bool bMain);
|
||||||
|
|
||||||
void AddNext(CBotDefParam* p);
|
void AddNext(CBotDefParam* p);
|
||||||
int GivType();
|
int GetType();
|
||||||
CBotTypResult GivTypResult();
|
CBotTypResult GetTypResult();
|
||||||
CBotDefParam* GivNext();
|
CBotDefParam* GetNext();
|
||||||
|
|
||||||
CBotString GivParamString();
|
CBotString GetParamString();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1720,8 +1720,8 @@ public:
|
||||||
static
|
static
|
||||||
void AddPublic(CBotFunction* pfunc);
|
void AddPublic(CBotFunction* pfunc);
|
||||||
|
|
||||||
CBotString GivName();
|
CBotString GetName();
|
||||||
CBotString GivParams();
|
CBotString GetParams();
|
||||||
bool IsPublic();
|
bool IsPublic();
|
||||||
bool IsExtern();
|
bool IsExtern();
|
||||||
CBotFunction* Next();
|
CBotFunction* Next();
|
||||||
|
|
|
@ -175,7 +175,7 @@ void CBotClass::FreeLock(CBotProgram* p)
|
||||||
bool CBotClass::AddItem(CBotString name, CBotTypResult type, int mPrivate)
|
bool CBotClass::AddItem(CBotString name, CBotTypResult type, int mPrivate)
|
||||||
{
|
{
|
||||||
CBotToken token(name, CBotString());
|
CBotToken token(name, CBotString());
|
||||||
CBotClass* pClass = type.GivClass();
|
CBotClass* pClass = type.GetClass();
|
||||||
|
|
||||||
CBotVar* pVar = CBotVar::Create( name, type );
|
CBotVar* pVar = CBotVar::Create( name, type );
|
||||||
/// pVar->SetUniqNum(CBotVar::NextUniqNum());
|
/// 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
|
// adds a new statement for the object initialization
|
||||||
pVar->m_InitExpr = new CBotNew() ;
|
pVar->m_InitExpr = new CBotNew() ;
|
||||||
CBotToken nom( pClass->GivName() );
|
CBotToken nom( pClass->GetName() );
|
||||||
pVar->m_InitExpr->SetToken(&nom);
|
pVar->m_InitExpr->SetToken(&nom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,12 +214,12 @@ void CBotClass::AddNext(CBotClass* pClass)
|
||||||
p->m_next = pClass;
|
p->m_next = pClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotString CBotClass::GivName()
|
CBotString CBotClass::GetName()
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotClass* CBotClass::GivParent()
|
CBotClass* CBotClass::GetParent()
|
||||||
{
|
{
|
||||||
if ( this == NULL ) return NULL;
|
if ( this == NULL ) return NULL;
|
||||||
return m_pParent;
|
return m_pParent;
|
||||||
|
@ -237,34 +237,34 @@ bool CBotClass::IsChildOf(CBotClass* pClass)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CBotVar* CBotClass::GivVar()
|
CBotVar* CBotClass::GetVar()
|
||||||
{
|
{
|
||||||
return m_pVar;
|
return m_pVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotVar* CBotClass::GivItem(const char* name)
|
CBotVar* CBotClass::GetItem(const char* name)
|
||||||
{
|
{
|
||||||
CBotVar* p = m_pVar;
|
CBotVar* p = m_pVar;
|
||||||
|
|
||||||
while ( p != NULL )
|
while ( p != NULL )
|
||||||
{
|
{
|
||||||
if ( p->GivName() == name ) return p;
|
if ( p->GetName() == name ) return p;
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
}
|
}
|
||||||
if ( m_pParent != NULL ) return m_pParent->GivItem(name);
|
if ( m_pParent != NULL ) return m_pParent->GetItem(name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotVar* CBotClass::GivItemRef(int nIdent)
|
CBotVar* CBotClass::GetItemRef(int nIdent)
|
||||||
{
|
{
|
||||||
CBotVar* p = m_pVar;
|
CBotVar* p = m_pVar;
|
||||||
|
|
||||||
while ( p != NULL )
|
while ( p != NULL )
|
||||||
{
|
{
|
||||||
if ( p->GivUniqNum() == nIdent ) return p;
|
if ( p->GetUniqNum() == nIdent ) return p;
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
}
|
}
|
||||||
if ( m_pParent != NULL ) return m_pParent->GivItemRef(nIdent);
|
if ( m_pParent != NULL ) return m_pParent->GetItemRef(nIdent);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ bool CBotClass::IsIntrinsic()
|
||||||
|
|
||||||
CBotClass* CBotClass::Find(CBotToken* &pToken)
|
CBotClass* CBotClass::Find(CBotToken* &pToken)
|
||||||
{
|
{
|
||||||
return Find(pToken->GivString());
|
return Find(pToken->GetString());
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotClass* CBotClass::Find(const char* name)
|
CBotClass* CBotClass::Find(const char* name)
|
||||||
|
@ -284,7 +284,7 @@ CBotClass* CBotClass::Find(const char* name)
|
||||||
|
|
||||||
while ( p != NULL )
|
while ( p != NULL )
|
||||||
{
|
{
|
||||||
if ( p->GivName() == name ) return p;
|
if ( p->GetName() == name ) return p;
|
||||||
p = p->m_ExNext;
|
p = p->m_ExNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ bool CBotClass::AddFunction(const char* name,
|
||||||
|
|
||||||
while ( p != NULL )
|
while ( p != NULL )
|
||||||
{
|
{
|
||||||
if ( name == p->GivName() )
|
if ( name == p->GetName() )
|
||||||
{
|
{
|
||||||
if ( pp == NULL ) m_pCalls = p->m_next;
|
if ( pp == NULL ) m_pCalls = p->m_next;
|
||||||
else pp->m_next = 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
|
// find the methods declared by AddFunction
|
||||||
|
|
||||||
CBotTypResult r = m_pCalls->CompileCall(name, pThis, ppParams, pStack, nIdent);
|
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
|
// find the methods declared by user
|
||||||
|
|
||||||
|
@ -384,21 +384,21 @@ bool CBotClass::SaveStaticState(FILE* pf)
|
||||||
{
|
{
|
||||||
if (!WriteWord( pf, 1)) return false;
|
if (!WriteWord( pf, 1)) return false;
|
||||||
// save the name of the class
|
// 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 )
|
while( pv != NULL )
|
||||||
{
|
{
|
||||||
if ( pv->IsStatic() )
|
if ( pv->IsStatic() )
|
||||||
{
|
{
|
||||||
if (!WriteWord( pf, 1)) return false;
|
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->Save0State(pf)) return false; // common header
|
||||||
if ( !pv->Save1State(pf) ) return false; // saves as the child class
|
if ( !pv->Save1State(pf) ) return false; // saves as the child class
|
||||||
if ( !WriteWord( pf, 0)) return false;
|
if ( !WriteWord( pf, 0)) return false;
|
||||||
}
|
}
|
||||||
pv = pv->GivNext();
|
pv = pv->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!WriteWord( pf, 0)) return false;
|
if (!WriteWord( pf, 0)) return false;
|
||||||
|
@ -435,7 +435,7 @@ bool CBotClass::RestoreStaticState(FILE* pf)
|
||||||
CBotVar* pv = NULL;
|
CBotVar* pv = NULL;
|
||||||
|
|
||||||
if (!ReadString( pf, VarName )) return false;
|
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
|
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
|
// seeks the corresponding classes
|
||||||
if ( pClass == NULL )
|
if ( pClass == NULL )
|
||||||
{
|
{
|
||||||
pStack->SetStartError(p->GivStart());
|
pStack->SetStartError(p->GetStart());
|
||||||
pClass = CBotClass::Find(p);
|
pClass = CBotClass::Find(p);
|
||||||
if ( pClass == NULL )
|
if ( pClass == NULL )
|
||||||
{
|
{
|
||||||
|
@ -483,7 +483,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
||||||
pStack->SetError(TX_NOCLASS, p);
|
pStack->SetError(TX_NOCLASS, p);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bIntrinsic = pClass->IsIntrinsic();
|
bool bIntrinsic = pClass->IsIntrinsic();
|
||||||
|
@ -495,7 +495,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
||||||
|
|
||||||
inst = new CBotClassInst();
|
inst = new CBotClassInst();
|
||||||
/// \TODO Need to be revised and fixed after adding unit tests
|
/// \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);
|
inst->SetToken(&token);
|
||||||
CBotToken* vartoken = p;
|
CBotToken* vartoken = p;
|
||||||
|
|
||||||
|
@ -504,8 +504,8 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
||||||
((CBotLeftExprVar*)inst->m_var)->m_typevar = type;
|
((CBotLeftExprVar*)inst->m_var)->m_typevar = type;
|
||||||
if (pStk->CheckVarLocal(vartoken)) // redefinition of the variable
|
if (pStk->CheckVarLocal(vartoken)) // redefinition of the variable
|
||||||
{
|
{
|
||||||
pStk->SetStartError(vartoken->GivStart());
|
pStk->SetStartError(vartoken->GetStart());
|
||||||
pStk->SetError(TX_REDEFVAR, vartoken->GivEnd());
|
pStk->SetError(TX_REDEFVAR, vartoken->GetEnd());
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,7 +520,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
||||||
|
|
||||||
if (!pStk->IsOk() )
|
if (!pStk->IsOk() )
|
||||||
{
|
{
|
||||||
pStk->SetError(TX_CLBRK, p->GivStart());
|
pStk->SetError(TX_CLBRK, p->GetStart());
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
goto suite; // no assignment, variable already created
|
goto suite; // no assignment, variable already created
|
||||||
|
@ -528,7 +528,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
||||||
|
|
||||||
|
|
||||||
CBotVar* var;
|
CBotVar* var;
|
||||||
var = CBotVar::Create(vartoken->GivString(), type); // creates the instance
|
var = CBotVar::Create(vartoken->GetString(), type); // creates the instance
|
||||||
// var->SetClass(pClass);
|
// var->SetClass(pClass);
|
||||||
var->SetUniqNum(
|
var->SetUniqNum(
|
||||||
((CBotLeftExprVar*)inst->m_var)->m_nIdent = CBotVar::NextUniqNum());
|
((CBotLeftExprVar*)inst->m_var)->m_nIdent = CBotVar::NextUniqNum());
|
||||||
|
@ -536,7 +536,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
||||||
pStack->AddVar(var); // placed on the stack
|
pStack->AddVar(var); // placed on the stack
|
||||||
|
|
||||||
// look if there are parameters
|
// look if there are parameters
|
||||||
inst->m_hasParams = (p->GivType() == ID_OPENPAR);
|
inst->m_hasParams = (p->GetType() == ID_OPENPAR);
|
||||||
|
|
||||||
CBotVar* ppVars[1000];
|
CBotVar* ppVars[1000];
|
||||||
inst->m_Parameters = CompileParams(p, pStk, ppVars);
|
inst->m_Parameters = CompileParams(p, pStk, ppVars);
|
||||||
|
@ -551,9 +551,9 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
||||||
{
|
{
|
||||||
// the constructor is there?
|
// the constructor is there?
|
||||||
// CBotString noname;
|
// 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
|
delete pStk->TokenStack(); // releases the supplement stack
|
||||||
int typ = r.GivType();
|
int typ = r.GetType();
|
||||||
|
|
||||||
if (typ == TX_UNDEFCALL)
|
if (typ == TX_UNDEFCALL)
|
||||||
{
|
{
|
||||||
|
@ -568,7 +568,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
||||||
|
|
||||||
if (typ>20)
|
if (typ>20)
|
||||||
{
|
{
|
||||||
pStk->SetError(typ, vartoken->GivEnd());
|
pStk->SetError(typ, vartoken->GetEnd());
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -578,7 +578,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
||||||
{
|
{
|
||||||
if (inst->m_hasParams)
|
if (inst->m_hasParams)
|
||||||
{
|
{
|
||||||
pStk->SetError(TX_ENDOF, p->GivStart());
|
pStk->SetError(TX_ENDOF, p->GetStart());
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,15 +586,15 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
||||||
{
|
{
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
CBotClass* result = pStk->GivClass();
|
CBotClass* result = pStk->GetClass();
|
||||||
if ( !pStk->GivTypResult(1).Eq(CBotTypNullPointer) &&
|
if ( !pStk->GetTypResult(1).Eq(CBotTypNullPointer) &&
|
||||||
( !pStk->GivTypResult(1).Eq(CBotTypPointer) ||
|
( !pStk->GetTypResult(1).Eq(CBotTypPointer) ||
|
||||||
( result != NULL && !pClass->IsChildOf(result) ))) // type compatible ?
|
( result != NULL && !pClass->IsChildOf(result) ))) // type compatible ?
|
||||||
{
|
{
|
||||||
pStk->SetError(TX_BADTYPE, p->GivStart());
|
pStk->SetError(TX_BADTYPE, p->GetStart());
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
// if ( !bIntrinsic ) var->SetPointer(pStk->GivVar()->GivPointer());
|
// if ( !bIntrinsic ) var->SetPointer(pStk->GetVar()->GetPointer());
|
||||||
if ( !bIntrinsic )
|
if ( !bIntrinsic )
|
||||||
{
|
{
|
||||||
// does not use the result on the stack, to impose the class
|
// does not use the result on the stack, to impose the class
|
||||||
|
@ -630,7 +630,7 @@ suite:
|
||||||
return pStack->Return(inst, pStk);
|
return pStack->Return(inst, pStk);
|
||||||
}
|
}
|
||||||
|
|
||||||
pStk->SetError(TX_ENDOF, p->GivStart());
|
pStk->SetError(TX_ENDOF, p->GetStart());
|
||||||
}
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
@ -655,9 +655,9 @@ bool CBotClassInst::Execute(CBotStack* &pj)
|
||||||
|
|
||||||
// creates the variable of type pointer to the object
|
// 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 )
|
if ( bIntrincic )
|
||||||
{
|
{
|
||||||
pThis = CBotVar::Create(name, CBotTypResult( CBotTypIntrinsic, pClass ));
|
pThis = CBotVar::Create(name, CBotTypResult( CBotTypIntrinsic, pClass ));
|
||||||
|
@ -674,7 +674,7 @@ bool CBotClassInst::Execute(CBotStack* &pj)
|
||||||
|
|
||||||
if ( pThis == NULL ) pThis = pile->FindVar(((CBotLeftExprVar*)m_var)->m_nIdent);
|
if ( pThis == NULL ) pThis = pile->FindVar(((CBotLeftExprVar*)m_var)->m_nIdent);
|
||||||
|
|
||||||
if ( pile->GivState()<3)
|
if ( pile->GetState()<3)
|
||||||
{
|
{
|
||||||
// ss there an assignment or parameters (contructor)
|
// ss there an assignment or parameters (contructor)
|
||||||
|
|
||||||
|
@ -687,18 +687,18 @@ bool CBotClassInst::Execute(CBotStack* &pj)
|
||||||
|
|
||||||
if ( bIntrincic )
|
if ( bIntrincic )
|
||||||
{
|
{
|
||||||
CBotVar* pv = pile->GivVar();
|
CBotVar* pv = pile->GetVar();
|
||||||
if ( pv == NULL || pv->GivPointer() == NULL )
|
if ( pv == NULL || pv->GetPointer() == NULL )
|
||||||
{
|
{
|
||||||
pile->SetError(TX_NULLPT, &m_token);
|
pile->SetError(TX_NULLPT, &m_token);
|
||||||
return pj->Return(pile);
|
return pj->Return(pile);
|
||||||
}
|
}
|
||||||
pThis->Copy(pile->GivVar(), false);
|
pThis->Copy(pile->GetVar(), false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CBotVarClass* pInstance;
|
CBotVarClass* pInstance;
|
||||||
pInstance = ((CBotVarPointer*)pile->GivVar())->GivPointer(); // value for the assignment
|
pInstance = ((CBotVarPointer*)pile->GetVar())->GetPointer(); // value for the assignment
|
||||||
pThis->SetPointer(pInstance);
|
pThis->SetPointer(pInstance);
|
||||||
}
|
}
|
||||||
pThis->SetInit(true);
|
pThis->SetInit(true);
|
||||||
|
@ -708,7 +708,7 @@ bool CBotClassInst::Execute(CBotStack* &pj)
|
||||||
{
|
{
|
||||||
// evaluates the constructor of an instance
|
// evaluates the constructor of an instance
|
||||||
|
|
||||||
if ( !bIntrincic && pile->GivState() == 1)
|
if ( !bIntrincic && pile->GetState() == 1)
|
||||||
{
|
{
|
||||||
CBotToken* pt = &m_token;
|
CBotToken* pt = &m_token;
|
||||||
CBotClass* pClass = CBotClass::Find(pt);
|
CBotClass* pClass = CBotClass::Find(pt);
|
||||||
|
@ -736,13 +736,13 @@ bool CBotClassInst::Execute(CBotStack* &pj)
|
||||||
if ( p != NULL) while ( true )
|
if ( p != NULL) while ( true )
|
||||||
{
|
{
|
||||||
pile2 = pile2->AddStack(); // place on the stack for the results
|
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?
|
if (!p->Execute(pile2)) return false; // interrupted here?
|
||||||
pile2->SetState(1);
|
pile2->SetState(1);
|
||||||
}
|
}
|
||||||
ppVars[i++] = pile2->GivVar();
|
ppVars[i++] = pile2->GetVar();
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
if ( p == NULL) break;
|
if ( p == NULL) break;
|
||||||
}
|
}
|
||||||
ppVars[i] = NULL;
|
ppVars[i] = NULL;
|
||||||
|
@ -750,15 +750,15 @@ bool CBotClassInst::Execute(CBotStack* &pj)
|
||||||
// creates a variable for the result
|
// creates a variable for the result
|
||||||
CBotVar* pResult = NULL; // constructor still void
|
CBotVar* pResult = NULL; // constructor still void
|
||||||
|
|
||||||
if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GivName(),
|
if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GetName(),
|
||||||
pThis, ppVars,
|
pThis, ppVars,
|
||||||
pResult, pile2, GivToken())) return false; // interrupt
|
pResult, pile2, GetToken())) return false; // interrupt
|
||||||
|
|
||||||
pThis->SetInit(true);
|
pThis->SetInit(true);
|
||||||
pThis->ConstructorSet(); // indicates that the constructor has been called
|
pThis->ConstructorSet(); // indicates that the constructor has been called
|
||||||
pile->Return(pile2); // releases a piece of stack
|
pile->Return(pile2); // releases a piece of stack
|
||||||
|
|
||||||
// pInstance = pThis->GivPointer();
|
// pInstance = pThis->GetPointer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -787,7 +787,7 @@ void CBotClassInst::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
|
||||||
// creates the variable of type pointer to the object
|
// 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 = pile->FindVar(name);
|
||||||
pThis->SetUniqNum(((CBotLeftExprVar*)m_var)->m_nIdent); // its attribute a unique number
|
pThis->SetUniqNum(((CBotLeftExprVar*)m_var)->m_nIdent); // its attribute a unique number
|
||||||
}
|
}
|
||||||
|
@ -796,7 +796,7 @@ void CBotClassInst::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
CBotClass* pClass = CBotClass::Find(pt);
|
CBotClass* pClass = CBotClass::Find(pt);
|
||||||
bool bIntrincic = pClass->IsIntrinsic();
|
bool bIntrincic = pClass->IsIntrinsic();
|
||||||
|
|
||||||
if ( bMain && pile->GivState()<3)
|
if ( bMain && pile->GetState()<3)
|
||||||
{
|
{
|
||||||
// is there an assignment or parameters (constructor)
|
// is there an assignment or parameters (constructor)
|
||||||
|
|
||||||
|
@ -813,7 +813,7 @@ void CBotClassInst::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
{
|
{
|
||||||
// evaluates the constructor of an instance
|
// evaluates the constructor of an instance
|
||||||
|
|
||||||
if ( !bIntrincic && pile->GivState() == 1)
|
if ( !bIntrincic && pile->GetState() == 1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -833,13 +833,13 @@ void CBotClassInst::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
pile2 = pile2->RestoreStack(); // place on the stack for the results
|
pile2 = pile2->RestoreStack(); // place on the stack for the results
|
||||||
if ( pile2 == NULL ) return;
|
if ( pile2 == NULL ) return;
|
||||||
|
|
||||||
if ( pile2->GivState() == 0 )
|
if ( pile2->GetState() == 0 )
|
||||||
{
|
{
|
||||||
p->RestoreState(pile2, bMain); // interrupted here?
|
p->RestoreState(pile2, bMain); // interrupted here?
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ppVars[i++] = pile2->GivVar();
|
ppVars[i++] = pile2->GetVar();
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
if ( p == NULL) break;
|
if ( p == NULL) break;
|
||||||
}
|
}
|
||||||
ppVars[i] = NULL;
|
ppVars[i] = NULL;
|
||||||
|
@ -847,7 +847,7 @@ void CBotClassInst::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
// creates a variable for the result
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -861,14 +861,14 @@ void CBotClassInst::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
|
||||||
bool CBotClass::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
|
bool CBotClass::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
|
||||||
{
|
{
|
||||||
CBotString name = pToken->GivString();
|
CBotString name = pToken->GetString();
|
||||||
|
|
||||||
if ( CBotCall::CheckCall(name) ) return true;
|
if ( CBotCall::CheckCall(name) ) return true;
|
||||||
|
|
||||||
CBotFunction* pp = m_pMethod;
|
CBotFunction* pp = m_pMethod;
|
||||||
while ( pp != NULL )
|
while ( pp != NULL )
|
||||||
{
|
{
|
||||||
if ( pToken->GivString() == pp->GivName() )
|
if ( pToken->GetString() == pp->GetName() )
|
||||||
{
|
{
|
||||||
// are their parameters exactly the same?
|
// are their parameters exactly the same?
|
||||||
if ( pp->CheckParam( pParam ) )
|
if ( pp->CheckParam( pParam ) )
|
||||||
|
|
|
@ -111,16 +111,16 @@ public:
|
||||||
|
|
||||||
~CBotTypResult();
|
~CBotTypResult();
|
||||||
|
|
||||||
int GivType(int mode = 0) const;
|
int GetType(int mode = 0) const;
|
||||||
// returns type CBotType* as a result
|
// returns type CBotType* as a result
|
||||||
|
|
||||||
void SetType(int n);
|
void SetType(int n);
|
||||||
// modifies a type
|
// modifies a type
|
||||||
|
|
||||||
CBotClass* GivClass() const;
|
CBotClass* GetClass() const;
|
||||||
// makes the pointer to the class (for CBotTypClass, CBotTypPointer)
|
// makes the pointer to the class (for CBotTypClass, CBotTypPointer)
|
||||||
|
|
||||||
int GivLimite() const;
|
int GetLimite() const;
|
||||||
// returns limit size of table (CBotTypArray)
|
// returns limit size of table (CBotTypArray)
|
||||||
|
|
||||||
void SetLimite(int n);
|
void SetLimite(int n);
|
||||||
|
@ -129,7 +129,7 @@ public:
|
||||||
void SetArray(int* max );
|
void SetArray(int* max );
|
||||||
// set limits for a list of dimensions (arrays of arrays)
|
// set limits for a list of dimensions (arrays of arrays)
|
||||||
|
|
||||||
CBotTypResult& GivTypElem() const;
|
CBotTypResult& GetTypElem() const;
|
||||||
// returns type of array elements (CBotTypArray)
|
// returns type of array elements (CBotTypArray)
|
||||||
// rend le type des éléments du tableau (CBotTypArray)
|
// rend le type des éléments du tableau (CBotTypArray)
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ public:
|
||||||
|
|
||||||
void Empty();
|
void Empty();
|
||||||
bool IsEmpty() const;
|
bool IsEmpty() const;
|
||||||
int GivLength();
|
int GetLength();
|
||||||
int Find(const char c);
|
int Find(const char c);
|
||||||
int Find(const char* lpsz);
|
int Find(const char* lpsz);
|
||||||
int ReverseFind(const char c);
|
int ReverseFind(const char c);
|
||||||
|
@ -338,7 +338,7 @@ public:
|
||||||
CBotStringArray();
|
CBotStringArray();
|
||||||
~CBotStringArray();
|
~CBotStringArray();
|
||||||
void SetSize(int nb);
|
void SetSize(int nb);
|
||||||
int GivSize();
|
int GetSize();
|
||||||
void Add(const CBotString& str);
|
void Add(const CBotString& str);
|
||||||
CBotString& operator[](int nIndex);
|
CBotString& operator[](int nIndex);
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ public:
|
||||||
// frees the static memory areas
|
// frees the static memory areas
|
||||||
|
|
||||||
static
|
static
|
||||||
int GivVersion();
|
int GetVersion();
|
||||||
// gives the version of the library CBOT
|
// gives the version of the library CBOT
|
||||||
|
|
||||||
|
|
||||||
|
@ -406,10 +406,10 @@ public:
|
||||||
void SetIdent(long n);
|
void SetIdent(long n);
|
||||||
// associates an identifier with the instance CBotProgram
|
// associates an identifier with the instance CBotProgram
|
||||||
|
|
||||||
long GivIdent();
|
long GetIdent();
|
||||||
// gives the identifier
|
// gives the identifier
|
||||||
|
|
||||||
int GivError();
|
int GetError();
|
||||||
bool GetError(int& code, int& start, int& end);
|
bool GetError(int& code, int& start, int& end);
|
||||||
bool GetError(int& code, int& start, int& end, CBotProgram* &pProg);
|
bool GetError(int& code, int& start, int& end, CBotProgram* &pProg);
|
||||||
// if true
|
// if true
|
||||||
|
@ -417,7 +417,7 @@ public:
|
||||||
// or execution
|
// or execution
|
||||||
// delimits the start and end block where the error
|
// delimits the start and end block where the error
|
||||||
// pProg lets you know what "module" has produced runtime 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);
|
bool Start(const char* name);
|
||||||
|
@ -437,7 +437,7 @@ public:
|
||||||
// FunctionName is a pointer made to the name of the function
|
// FunctionName is a pointer made to the name of the function
|
||||||
// start and end position in the text of the token processing
|
// 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
|
// 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
|
// 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)
|
// the return value (CBotVar *) is a variable list (or NULL)
|
||||||
|
@ -480,7 +480,7 @@ public:
|
||||||
// see the above modes in CBotGet
|
// see the above modes in CBotGet
|
||||||
|
|
||||||
|
|
||||||
CBotFunction* GivFunctions();
|
CBotFunction* GetFunctions();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -513,8 +513,8 @@ int cMean(CBotVar* &pVar, CBotString& ClassName)
|
||||||
|
|
||||||
while ( pVar != NULL )
|
while ( pVar != NULL )
|
||||||
{
|
{
|
||||||
if ( pVar->GivType() > CBotTypDouble ) return 6002; // this is not a number
|
if ( pVar->GetType() > CBotTypDouble ) return 6002; // this is not a number
|
||||||
pVar = pVar -> GivNext();
|
pVar = pVar -> GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
return CBotTypFloat; // the type of the result may depend on the parameters!
|
return CBotTypFloat; // the type of the result may depend on the parameters!
|
||||||
|
@ -527,8 +527,8 @@ bool rMean(CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
int nb = 0;
|
int nb = 0;
|
||||||
while (pVar != NULL)
|
while (pVar != NULL)
|
||||||
{
|
{
|
||||||
total += pVar->GivValFloat();
|
total += pVar->GetValFloat();
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
nb++;
|
nb++;
|
||||||
}
|
}
|
||||||
pResult->SetValFloat(total/nb); // returns the mean value
|
pResult->SetValFloat(total/nb); // returns the mean value
|
||||||
|
@ -544,7 +544,7 @@ bool rMean(CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
// may be useful to the outside of the module
|
// may be useful to the outside of the module
|
||||||
// ( it is currently not expected to be able to create these objects in outer )
|
// ( 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_UNDEF 0 // undefined variable
|
||||||
#define IS_DEF 1 // variable defined
|
#define IS_DEF 1 // variable defined
|
||||||
#define IS_NAN 999 // variable defined as not a number
|
#define IS_NAN 999 // variable defined as not a number
|
||||||
|
@ -615,33 +615,33 @@ virtual ~CBotVar( ); // destructor
|
||||||
// associates a unique identifier to an instance
|
// associates a unique identifier to an instance
|
||||||
// ( it is used to ensure that the id is unique)
|
// ( it is used to ensure that the id is unique)
|
||||||
|
|
||||||
void* GivUserPtr();
|
void* GetUserPtr();
|
||||||
// makes the pointer associated with the variable
|
// 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
|
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
|
// 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 SetType(CBotTypResult& type);
|
||||||
|
|
||||||
void SetInit(int bInit); // is the variable in the state IS_UNDEF, IS_DEF, IS_NAN
|
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);
|
void SetStatic(bool bStatic);
|
||||||
bool IsStatic();
|
bool IsStatic();
|
||||||
|
|
||||||
void SetPrivate(int mPrivate);
|
void SetPrivate(int mPrivate);
|
||||||
bool IsPrivate(int mode = PR_PROTECT);
|
bool IsPrivate(int mode = PR_PROTECT);
|
||||||
int GivPrivate();
|
int GetPrivate();
|
||||||
|
|
||||||
virtual
|
virtual
|
||||||
void ConstructorSet();
|
void ConstructorSet();
|
||||||
|
@ -649,23 +649,23 @@ virtual ~CBotVar( ); // destructor
|
||||||
void SetVal(CBotVar* var); // remprend une valeur
|
void SetVal(CBotVar* var); // remprend une valeur
|
||||||
// TODO remprend value
|
// TODO remprend value
|
||||||
virtual
|
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
|
virtual
|
||||||
CBotVar* GivItemRef(int nIdent); // idem à partir du n° ref
|
CBotVar* GetItemRef(int nIdent); // idem à partir du n° ref
|
||||||
// TODO ditto from ref no.
|
// TODO ditto from ref no.
|
||||||
virtual
|
virtual
|
||||||
CBotVar* GivItem(int row, bool bGrow = false);
|
CBotVar* GetItem(int row, bool bGrow = false);
|
||||||
|
|
||||||
virtual
|
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);
|
bool IsElemOfClass(const char* name);
|
||||||
// said if the element belongs to the class "name"
|
// said if the element belongs to the class "name"
|
||||||
// makes true if the object is a subclass
|
// 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
|
void AddNext(CBotVar* pVar); // added to a list
|
||||||
|
@ -683,23 +683,23 @@ virtual ~CBotVar( ); // destructor
|
||||||
virtual void SetValString(const char* p);// initialized with a string value (#)
|
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
|
virtual
|
||||||
CBotString GivValString(); // request the string value (#)
|
CBotString GetValString(); // request the string value (#)
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
virtual void SetClass(CBotClass* pClass);
|
virtual void SetClass(CBotClass* pClass);
|
||||||
virtual
|
virtual
|
||||||
CBotClass* GivClass();
|
CBotClass* GetClass();
|
||||||
|
|
||||||
virtual void SetPointer(CBotVar* p);
|
virtual void SetPointer(CBotVar* p);
|
||||||
virtual
|
virtual
|
||||||
CBotVarClass* GivPointer();
|
CBotVarClass* GetPointer();
|
||||||
// virtual void SetIndirection(CBotVar* pVar);
|
// virtual void SetIndirection(CBotVar* pVar);
|
||||||
|
|
||||||
virtual void Add(CBotVar* left, CBotVar* right); // addition
|
virtual void Add(CBotVar* left, CBotVar* right); // addition
|
||||||
|
@ -736,13 +736,13 @@ virtual ~CBotVar( ); // destructor
|
||||||
void debug();
|
void debug();
|
||||||
|
|
||||||
// virtual
|
// virtual
|
||||||
// CBotVar* GivMyThis();
|
// CBotVar* GetMyThis();
|
||||||
|
|
||||||
virtual
|
virtual
|
||||||
void Maj(void* pUser = NULL, bool bContinue = true);
|
void Maj(void* pUser = NULL, bool bContinue = true);
|
||||||
|
|
||||||
void SetUniqNum(long n);
|
void SetUniqNum(long n);
|
||||||
long GivUniqNum();
|
long GetUniqNum();
|
||||||
static long NextUniqNum();
|
static long NextUniqNum();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -751,12 +751,12 @@ virtual ~CBotVar( ); // destructor
|
||||||
can be called with objects which are respectively integer, real or string
|
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
|
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,
|
use value conversions,
|
||||||
GivValString() works on numbers (makes the corresponding string)
|
GetValString() works on numbers (makes the corresponding string)
|
||||||
but do not make GivValInt () with a string variable!
|
but do not make GetValInt () with a string variable!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -824,8 +824,8 @@ public:
|
||||||
// adds an element by giving an element of type CBotVar
|
// adds an element by giving an element of type CBotVar
|
||||||
void AddNext(CBotClass* pClass);
|
void AddNext(CBotClass* pClass);
|
||||||
|
|
||||||
CBotString GivName(); // gives the name of the class
|
CBotString GetName(); // gives the name of the class
|
||||||
CBotClass* GivParent(); // gives the parent class (or NULL)
|
CBotClass* GetParent(); // gives the parent class (or NULL)
|
||||||
|
|
||||||
// true if a class is derived (Extends) of another
|
// true if a class is derived (Extends) of another
|
||||||
// return true also if the classes are identical
|
// return true also if the classes are identical
|
||||||
|
@ -837,9 +837,9 @@ public:
|
||||||
static
|
static
|
||||||
CBotClass* Find(const char* name);
|
CBotClass* Find(const char* name);
|
||||||
|
|
||||||
CBotVar* GivVar(); // return the list of variables
|
CBotVar* GetVar(); // return the list of variables
|
||||||
CBotVar* GivItem(const char* name); // one of the variables according to its name
|
CBotVar* GetItem(const char* name); // one of the variables according to its name
|
||||||
CBotVar* GivItemRef(int nIdent);
|
CBotVar* GetItemRef(int nIdent);
|
||||||
|
|
||||||
CBotTypResult CompileMethode(const char* name, CBotVar* pThis, CBotVar** ppParams,
|
CBotTypResult CompileMethode(const char* name, CBotVar* pThis, CBotVar** ppParams,
|
||||||
CBotCStack* pStack, long& nIdent);
|
CBotCStack* pStack, long& nIdent);
|
||||||
|
@ -922,9 +922,9 @@ private:
|
||||||
* \brief Check whether given parameter is a keyword
|
* \brief Check whether given parameter is a keyword
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
int GivKeyWords(const char* w); // is it a keyword?
|
int GetKeyWords(const char* w); // is it a keyword?
|
||||||
static
|
static
|
||||||
bool GivKeyDefNum(const char* w, CBotToken* &token);
|
bool GetKeyDefNum(const char* w, CBotToken* &token);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Loads the list of keywords
|
* \brief Loads the list of keywords
|
||||||
|
@ -948,35 +948,35 @@ public:
|
||||||
/**
|
/**
|
||||||
* \brief Returns the type of token
|
* \brief Returns the type of token
|
||||||
*/
|
*/
|
||||||
int GivType();
|
int GetType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief makes the string corresponding to this token
|
* \brief makes the string corresponding to this token
|
||||||
*/
|
*/
|
||||||
CBotString& GivString();
|
CBotString& GetString();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief makes the following separator token
|
* \brief makes the following separator token
|
||||||
*/
|
*/
|
||||||
CBotString& GivSep();
|
CBotString& GetSep();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief position of the beginning in the text
|
* \brief position of the beginning in the text
|
||||||
*/
|
*/
|
||||||
int GivStart();
|
int GetStart();
|
||||||
/**
|
/**
|
||||||
* \brief end position in the text
|
* \brief end position in the text
|
||||||
*/
|
*/
|
||||||
int GivEnd();
|
int GetEnd();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief gives the next token in the list
|
* \brief gives the next token in the list
|
||||||
*/
|
*/
|
||||||
CBotToken* GivNext();
|
CBotToken* GetNext();
|
||||||
/**
|
/**
|
||||||
* \brief gives the previous token in a list
|
* \brief gives the previous token in a list
|
||||||
*/
|
*/
|
||||||
CBotToken* GivPrev();
|
CBotToken* GetPrev();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief transforms the entire program
|
* \brief transforms the entire program
|
||||||
|
@ -997,7 +997,7 @@ public:
|
||||||
void SetString(const char* name);
|
void SetString(const char* name);
|
||||||
|
|
||||||
void SetPos(int start, int end);
|
void SetPos(int start, int end);
|
||||||
long GivIdKey();
|
long GetIdKey();
|
||||||
/**
|
/**
|
||||||
* \brief adds a token (a copy)
|
* \brief adds a token (a copy)
|
||||||
*/
|
*/
|
||||||
|
@ -1091,7 +1091,7 @@ public:
|
||||||
// routine that implements the GOTO (CPoint pos)
|
// routine that implements the GOTO (CPoint pos)
|
||||||
bool rDoGoto( CBotVar* pVar, CBotVar* pResult, int& exception )
|
bool rDoGoto( CBotVar* pVar, CBotVar* pResult, int& exception )
|
||||||
{
|
{
|
||||||
if (pVar->GivType() != CBotTypeClass ||
|
if (pVar->GetType() != CBotTypeClass ||
|
||||||
pVar->IsElemOfClas("CPoint") ) { exception = 6522; return false; )
|
pVar->IsElemOfClas("CPoint") ) { exception = 6522; return false; )
|
||||||
// the parameter is not the right class?
|
// the parameter is not the right class?
|
||||||
// in fact the control is done to the routine of compilation
|
// in fact the control is done to the routine of compilation
|
||||||
|
@ -1100,13 +1100,13 @@ bool rDoGoto( CBotVar* pVar, CBotVar* pResult, int& exception )
|
||||||
|
|
||||||
// or so
|
// or so
|
||||||
CBotVar* temp;
|
CBotVar* temp;
|
||||||
temp = pVar->GivItem("x"); // is necessary for the object of type CPoint
|
temp = pVar->GetItem("x"); // is necessary for the object of type CPoint
|
||||||
ASSERT (temp != NULL && temp->GivType() == CBotTypFloat);
|
ASSERT (temp != NULL && temp->GetType() == CBotTypFloat);
|
||||||
m_PosToGo.x = temp->GivValFloat();
|
m_PosToGo.x = temp->GetValFloat();
|
||||||
|
|
||||||
temp = pVar->GivItem("y"); // is necessary for the object of type CPoint
|
temp = pVar->GetItem("y"); // is necessary for the object of type CPoint
|
||||||
ASSERT (temp != NULL && temp->GivType() == CBotTypFloat);
|
ASSERT (temp != NULL && temp->GetType() == CBotTypFloat);
|
||||||
m_PosToGo.y = temp->GivValFloat();
|
m_PosToGo.y = temp->GetValFloat();
|
||||||
|
|
||||||
return (m_CurentPos == m_PosToGo); // makes true if the position is reached
|
return (m_CurentPos == m_PosToGo); // makes true if the position is reached
|
||||||
// returns false if one had wait yet
|
// returns false if one had wait yet
|
||||||
|
|
|
@ -77,40 +77,40 @@ bool CBotFunction::IsExtern()
|
||||||
|
|
||||||
bool CBotFunction::GetPosition(int& start, int& stop, CBotGet modestart, CBotGet modestop)
|
bool CBotFunction::GetPosition(int& start, int& stop, CBotGet modestart, CBotGet modestop)
|
||||||
{
|
{
|
||||||
start = m_extern.GivStart();
|
start = m_extern.GetStart();
|
||||||
stop = m_closeblk.GivEnd();
|
stop = m_closeblk.GetEnd();
|
||||||
|
|
||||||
if (modestart == GetPosExtern)
|
if (modestart == GetPosExtern)
|
||||||
{
|
{
|
||||||
start = m_extern.GivStart();
|
start = m_extern.GetStart();
|
||||||
}
|
}
|
||||||
if (modestop == GetPosExtern)
|
if (modestop == GetPosExtern)
|
||||||
{
|
{
|
||||||
stop = m_extern.GivEnd();
|
stop = m_extern.GetEnd();
|
||||||
}
|
}
|
||||||
if (modestart == GetPosNom)
|
if (modestart == GetPosNom)
|
||||||
{
|
{
|
||||||
start = m_token.GivStart();
|
start = m_token.GetStart();
|
||||||
}
|
}
|
||||||
if (modestop == GetPosNom)
|
if (modestop == GetPosNom)
|
||||||
{
|
{
|
||||||
stop = m_token.GivEnd();
|
stop = m_token.GetEnd();
|
||||||
}
|
}
|
||||||
if (modestart == GetPosParam)
|
if (modestart == GetPosParam)
|
||||||
{
|
{
|
||||||
start = m_openpar.GivStart();
|
start = m_openpar.GetStart();
|
||||||
}
|
}
|
||||||
if (modestop == GetPosParam)
|
if (modestop == GetPosParam)
|
||||||
{
|
{
|
||||||
stop = m_closepar.GivEnd();
|
stop = m_closepar.GetEnd();
|
||||||
}
|
}
|
||||||
if (modestart == GetPosBloc)
|
if (modestart == GetPosBloc)
|
||||||
{
|
{
|
||||||
start = m_openblk.GivStart();
|
start = m_openblk.GetStart();
|
||||||
}
|
}
|
||||||
if (modestop == GetPosBloc)
|
if (modestop == GetPosBloc)
|
||||||
{
|
{
|
||||||
stop = m_closeblk.GivEnd();
|
stop = m_closeblk.GetEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -123,7 +123,7 @@ CBotTypResult ArrayType(CBotToken* &p, CBotCStack* pile, CBotTypResult type)
|
||||||
{
|
{
|
||||||
if ( !IsOfType( p, ID_CLBRK ) )
|
if ( !IsOfType( p, ID_CLBRK ) )
|
||||||
{
|
{
|
||||||
pile->SetError(TX_CLBRK, p->GivStart());
|
pile->SetError(TX_CLBRK, p->GetStart());
|
||||||
return CBotTypResult( -1 );
|
return CBotTypResult( -1 );
|
||||||
}
|
}
|
||||||
type = CBotTypResult( CBotTypArrayPointer, type );
|
type = CBotTypResult( CBotTypArrayPointer, type );
|
||||||
|
@ -135,30 +135,30 @@ CBotTypResult TypeParam(CBotToken* &p, CBotCStack* pile)
|
||||||
{
|
{
|
||||||
CBotClass* pClass = NULL;
|
CBotClass* pClass = NULL;
|
||||||
|
|
||||||
switch (p->GivType())
|
switch (p->GetType())
|
||||||
{
|
{
|
||||||
case ID_INT:
|
case ID_INT:
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
return ArrayType(p, pile, CBotTypResult( CBotTypInt ));
|
return ArrayType(p, pile, CBotTypResult( CBotTypInt ));
|
||||||
case ID_FLOAT:
|
case ID_FLOAT:
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
return ArrayType(p, pile, CBotTypResult( CBotTypFloat ));
|
return ArrayType(p, pile, CBotTypResult( CBotTypFloat ));
|
||||||
case ID_BOOLEAN:
|
case ID_BOOLEAN:
|
||||||
case ID_BOOL:
|
case ID_BOOL:
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
return ArrayType(p, pile, CBotTypResult( CBotTypBoolean ));
|
return ArrayType(p, pile, CBotTypResult( CBotTypBoolean ));
|
||||||
case ID_STRING:
|
case ID_STRING:
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
return ArrayType(p, pile, CBotTypResult( CBotTypString ));
|
return ArrayType(p, pile, CBotTypResult( CBotTypString ));
|
||||||
case ID_VOID:
|
case ID_VOID:
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
return CBotTypResult( 0 );
|
return CBotTypResult( 0 );
|
||||||
|
|
||||||
case TokenTypVar:
|
case TokenTypVar:
|
||||||
pClass = CBotClass::Find(p);
|
pClass = CBotClass::Find(p);
|
||||||
if ( pClass != NULL)
|
if ( pClass != NULL)
|
||||||
{
|
{
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
return ArrayType(p, pile,
|
return ArrayType(p, pile,
|
||||||
pClass->IsIntrinsic() ?
|
pClass->IsIntrinsic() ?
|
||||||
CBotTypResult( CBotTypIntrinsic, pClass ) :
|
CBotTypResult( CBotTypIntrinsic, pClass ) :
|
||||||
|
@ -203,14 +203,14 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
|
||||||
// CBotClass* pClass;
|
// CBotClass* pClass;
|
||||||
func->m_retTyp = TypeParam(p, pStk); // type of the result
|
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;
|
CBotToken* pp = p;
|
||||||
func->m_token = *p;
|
func->m_token = *p;
|
||||||
|
|
||||||
if ( IsOfType(p, ID_NOT) )
|
if ( IsOfType(p, ID_NOT) )
|
||||||
{
|
{
|
||||||
CBotToken d("~" + p->GivString());
|
CBotToken d("~" + p->GetString());
|
||||||
func->m_token = d;
|
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
|
if ( IsOfType( p, ID_DBLDOTS ) ) // method for a class
|
||||||
{
|
{
|
||||||
func->m_MasterClass = pp->GivString();
|
func->m_MasterClass = pp->GetString();
|
||||||
CBotClass* pClass = CBotClass::Find(pp);
|
CBotClass* pClass = CBotClass::Find(pp);
|
||||||
if ( pClass == NULL ) goto bad;
|
if ( pClass == NULL ) goto bad;
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
|
||||||
}
|
}
|
||||||
func->m_openpar = p;
|
func->m_openpar = p;
|
||||||
func->m_Param = CBotDefParam::Compile( p, pStk );
|
func->m_Param = CBotDefParam::Compile( p, pStk );
|
||||||
func->m_closepar = p->GivPrev();
|
func->m_closepar = p->GetPrev();
|
||||||
if (pStk->IsOk())
|
if (pStk->IsOk())
|
||||||
{
|
{
|
||||||
pStk->SetRetType(func->m_retTyp); // for knowledge what type returns
|
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
|
// initialize variables acording to This
|
||||||
// only saves the pointer to the first,
|
// only saves the pointer to the first,
|
||||||
// the rest is chained
|
// the rest is chained
|
||||||
CBotVar* pv = pThis->GivItemList();
|
CBotVar* pv = pThis->GetItemList();
|
||||||
// int num = 1;
|
// int num = 1;
|
||||||
while (pv != NULL)
|
while (pv != NULL)
|
||||||
{
|
{
|
||||||
CBotVar* pcopy = CBotVar::Create(pv);
|
CBotVar* pcopy = CBotVar::Create(pv);
|
||||||
// pcopy->SetInit(2);
|
// pcopy->SetInit(2);
|
||||||
pcopy->Copy(pv);
|
pcopy->Copy(pv);
|
||||||
pcopy->SetPrivate(pv->GivPrivate());
|
pcopy->SetPrivate(pv->GetPrivate());
|
||||||
// pcopy->SetUniqNum(pv->GivUniqNum()); //num++);
|
// pcopy->SetUniqNum(pv->GetUniqNum()); //num++);
|
||||||
pStk->AddVar(pcopy);
|
pStk->AddVar(pcopy);
|
||||||
pv = pv->GivNext();
|
pv = pv->GetNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// and compiles the following instruction block
|
// and compiles the following instruction block
|
||||||
func->m_openblk = p;
|
func->m_openblk = p;
|
||||||
func->m_Block = CBotBlock::Compile(p, pStk, false);
|
func->m_Block = CBotBlock::Compile(p, pStk, false);
|
||||||
func->m_closeblk = p->GivPrev();
|
func->m_closeblk = p->GetPrev();
|
||||||
if ( pStk->IsOk() )
|
if ( pStk->IsOk() )
|
||||||
{
|
{
|
||||||
if ( func->m_bPublic ) // public function, return known for all
|
if ( func->m_bPublic ) // public function, return known for all
|
||||||
|
@ -309,7 +309,7 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
|
||||||
func->m_retToken = *p;
|
func->m_retToken = *p;
|
||||||
func->m_retTyp = TypeParam(p, pStack); // type of the result
|
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;
|
CBotToken* pp = p;
|
||||||
func->m_token = *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
|
if ( IsOfType( p, ID_DBLDOTS ) ) // method for a class
|
||||||
{
|
{
|
||||||
func->m_MasterClass = pp->GivString();
|
func->m_MasterClass = pp->GetString();
|
||||||
CBotClass* pClass = CBotClass::Find(pp);
|
CBotClass* pClass = CBotClass::Find(pp);
|
||||||
if ( pClass == NULL )
|
if ( pClass == NULL )
|
||||||
{
|
{
|
||||||
|
@ -344,8 +344,8 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
|
||||||
// and skips the following instruction block
|
// and skips the following instruction block
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
int type = p->GivType();
|
int type = p->GetType();
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
if (type == ID_OPBLK) level++;
|
if (type == ID_OPBLK) level++;
|
||||||
if (type == ID_CLBLK) 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
|
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
|
if ( !m_Param->Execute(ppVars, pile) ) return false; // define parameters
|
||||||
pile->IncState();
|
pile->IncState();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pile->GivState() == 1 && !m_MasterClass.IsEmpty() )
|
if ( pile->GetState() == 1 && !m_MasterClass.IsEmpty() )
|
||||||
{
|
{
|
||||||
// makes "this" known
|
// makes "this" known
|
||||||
CBotVar* pThis ;
|
CBotVar* pThis ;
|
||||||
|
@ -410,7 +410,7 @@ bool CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance)
|
||||||
|
|
||||||
if ( !m_Block->Execute(pile) )
|
if ( !m_Block->Execute(pile) )
|
||||||
{
|
{
|
||||||
if ( pile->GivError() < 0 )
|
if ( pile->GetError() < 0 )
|
||||||
pile->SetError( 0 );
|
pile->SetError( 0 );
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
@ -428,11 +428,11 @@ void CBotFunction::RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInst
|
||||||
|
|
||||||
pile->SetBotCall(m_pProg); // bases for routines
|
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
|
CBotStack* pile2 = pile->RestoreStack(NULL); // one end of stack local to this function
|
||||||
if ( pile2 == NULL ) return;
|
if ( pile2 == NULL ) return;
|
||||||
pile->SetState(pile->GivState() + pile2->GivState());
|
pile->SetState(pile->GetState() + pile2->GetState());
|
||||||
pile2->Delete();
|
pile2->Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CB
|
||||||
{
|
{
|
||||||
for ( pt = this ; pt != NULL ; pt = pt->m_next )
|
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 i = 0;
|
||||||
int alpha = 0; // signature of parameters
|
int alpha = 0; // signature of parameters
|
||||||
|
@ -516,15 +516,15 @@ CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CB
|
||||||
CBotVar* pw = ppVars[i++]; // provided list parameter
|
CBotVar* pw = ppVars[i++]; // provided list parameter
|
||||||
while ( pv != NULL && pw != NULL)
|
while ( pv != NULL && pw != NULL)
|
||||||
{
|
{
|
||||||
if (!TypesCompatibles(pv->GivTypResult(), pw->GivTypResult()))
|
if (!TypesCompatibles(pv->GetTypResult(), pw->GetTypResult()))
|
||||||
{
|
{
|
||||||
if ( pFunc == NULL ) TypeOrError = TX_BADPARAM;
|
if ( pFunc == NULL ) TypeOrError = TX_BADPARAM;
|
||||||
break;
|
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!
|
alpha += d>0 ? d : -10*d; // quality loss, 10 times more expensive!
|
||||||
|
|
||||||
pv = pv->GivNext();
|
pv = pv->GetNext();
|
||||||
pw = ppVars[i++];
|
pw = ppVars[i++];
|
||||||
}
|
}
|
||||||
if ( pw != NULL )
|
if ( pw != NULL )
|
||||||
|
@ -562,7 +562,7 @@ CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CB
|
||||||
{
|
{
|
||||||
for ( pt = m_listPublic ; pt != NULL ; pt = pt->m_nextpublic )
|
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 i = 0;
|
||||||
int alpha = 0; // signature of parameters
|
int alpha = 0; // signature of parameters
|
||||||
|
@ -571,15 +571,15 @@ CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CB
|
||||||
CBotVar* pw = ppVars[i++]; // list of provided parameters
|
CBotVar* pw = ppVars[i++]; // list of provided parameters
|
||||||
while ( pv != NULL && pw != NULL)
|
while ( pv != NULL && pw != NULL)
|
||||||
{
|
{
|
||||||
if (!TypesCompatibles(pv->GivTypResult(), pw->GivTypResult()))
|
if (!TypesCompatibles(pv->GetTypResult(), pw->GetTypResult()))
|
||||||
{
|
{
|
||||||
if ( pFunc == NULL ) TypeOrError = TX_BADPARAM;
|
if ( pFunc == NULL ) TypeOrError = TX_BADPARAM;
|
||||||
break;
|
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!
|
alpha += d>0 ? d : -10*d; // quality loss, 10 times more expensive!
|
||||||
|
|
||||||
pv = pv->GivNext();
|
pv = pv->GetNext();
|
||||||
pw = ppVars[i++];
|
pw = ppVars[i++];
|
||||||
}
|
}
|
||||||
if ( pw != NULL )
|
if ( pw != NULL )
|
||||||
|
@ -645,7 +645,7 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar** ppVars, CBotS
|
||||||
|
|
||||||
// preparing parameters on the stack
|
// preparing parameters on the stack
|
||||||
|
|
||||||
if ( pStk1->GivState() == 0 )
|
if ( pStk1->GetState() == 0 )
|
||||||
{
|
{
|
||||||
if ( !pt->m_MasterClass.IsEmpty() )
|
if ( !pt->m_MasterClass.IsEmpty() )
|
||||||
{
|
{
|
||||||
|
@ -677,13 +677,13 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar** ppVars, CBotS
|
||||||
|
|
||||||
// finally execution of the found function
|
// finally execution of the found function
|
||||||
|
|
||||||
if ( !pStk3->GivRetVar( // puts the result on the stack
|
if ( !pStk3->GetRetVar( // puts the result on the stack
|
||||||
pt->m_Block->Execute(pStk3) )) // GivRetVar said if it is interrupted
|
pt->m_Block->Execute(pStk3) )) // GetRetVar said if it is interrupted
|
||||||
{
|
{
|
||||||
if ( !pStk3->IsOk() && pt->m_pProg != m_pProg )
|
if ( !pStk3->IsOk() && pt->m_pProg != m_pProg )
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if ( m_pProg->GivFunctions()->GivName() == "LaCommande" ) return false;
|
if ( m_pProg->GetFunctions()->GetName() == "LaCommande" ) return false;
|
||||||
#endif
|
#endif
|
||||||
pStk3->SetPosError(pToken); // indicates the error on the procedure call
|
pStk3->SetPosError(pToken); // indicates the error on the procedure call
|
||||||
}
|
}
|
||||||
|
@ -713,7 +713,7 @@ void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar** ppVars,
|
||||||
|
|
||||||
pStk1->SetBotCall(pt->m_pProg); // it may have changed module
|
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
|
CBotStack* pStk2 = pStk1->RestoreStack(NULL); // used more
|
||||||
if ( pStk2 == NULL ) return;
|
if ( pStk2 == NULL ) return;
|
||||||
|
@ -739,7 +739,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);
|
pt->m_Param->RestoreState(pStk3, true);
|
||||||
return;
|
return;
|
||||||
|
@ -759,13 +759,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)
|
int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken, CBotClass* pClass)
|
||||||
{
|
{
|
||||||
CBotTypResult type;
|
CBotTypResult type;
|
||||||
CBotProgram* pProgCurrent = pStack->GivBotCall();
|
CBotProgram* pProgCurrent = pStack->GetBotCall();
|
||||||
|
|
||||||
CBotFunction* pt = FindLocalOrPublic(nIdent, name, ppVars, type, false);
|
CBotFunction* pt = FindLocalOrPublic(nIdent, name, ppVars, type, false);
|
||||||
|
|
||||||
if ( pt != NULL )
|
if ( pt != NULL )
|
||||||
{
|
{
|
||||||
// DEBUG( "CBotFunction::DoCall" + pt->GivName(), 0, pStack);
|
// DEBUG( "CBotFunction::DoCall" + pt->GetName(), 0, pStack);
|
||||||
|
|
||||||
CBotStack* pStk = pStack->AddStack(pt, 2);
|
CBotStack* pStk = pStack->AddStack(pt, 2);
|
||||||
// if ( pStk == EOX ) return true;
|
// if ( pStk == EOX ) return true;
|
||||||
|
@ -775,7 +775,7 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
|
||||||
|
|
||||||
// preparing parameters on the stack
|
// preparing parameters on the stack
|
||||||
|
|
||||||
if ( pStk->GivState() == 0 )
|
if ( pStk->GetState() == 0 )
|
||||||
{
|
{
|
||||||
// sets the variable "this" on the stack
|
// sets the variable "this" on the stack
|
||||||
CBotVar* pthis = CBotVar::Create("this", CBotTypNullPointer);
|
CBotVar* pthis = CBotVar::Create("this", CBotTypNullPointer);
|
||||||
|
@ -783,7 +783,7 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
|
||||||
pthis->SetUniqNum(-2); // special value
|
pthis->SetUniqNum(-2); // special value
|
||||||
pStk->AddVar(pthis);
|
pStk->AddVar(pthis);
|
||||||
|
|
||||||
CBotClass* pClass = pThis->GivClass()->GivParent();
|
CBotClass* pClass = pThis->GetClass()->GetParent();
|
||||||
if ( pClass )
|
if ( pClass )
|
||||||
{
|
{
|
||||||
// sets the variable "super" on the stack
|
// sets the variable "super" on the stack
|
||||||
|
@ -797,19 +797,19 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
|
||||||
pStk->IncState();
|
pStk->IncState();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pStk->GivState() == 1 )
|
if ( pStk->GetState() == 1 )
|
||||||
{
|
{
|
||||||
if ( pt->m_bSynchro )
|
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
|
if ( !pClass->Lock(pProgBase) ) return false; // expected to power \TODO attend de pouvoir
|
||||||
}
|
}
|
||||||
pStk->IncState();
|
pStk->IncState();
|
||||||
}
|
}
|
||||||
// finally calls the found function
|
// finally calls the found function
|
||||||
|
|
||||||
if ( !pStk3->GivRetVar( // puts the result on the stack
|
if ( !pStk3->GetRetVar( // puts the result on the stack
|
||||||
pt->m_Block->Execute(pStk3) )) // GivRetVar said if it is interrupted
|
pt->m_Block->Execute(pStk3) )) // GetRetVar said if it is interrupted
|
||||||
{
|
{
|
||||||
if ( !pStk3->IsOk() )
|
if ( !pStk3->IsOk() )
|
||||||
{
|
{
|
||||||
|
@ -855,10 +855,10 @@ void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar* pThis, C
|
||||||
|
|
||||||
pt->m_Param->RestoreState(pStk3, true); // parameters
|
pt->m_Param->RestoreState(pStk3, true); // parameters
|
||||||
|
|
||||||
if ( pStk->GivState() > 1 && // latching is effective?
|
if ( pStk->GetState() > 1 && // latching is effective?
|
||||||
pt->m_bSynchro )
|
pt->m_bSynchro )
|
||||||
{
|
{
|
||||||
CBotProgram* pProgBase = pStk->GivBotCall(true);
|
CBotProgram* pProgBase = pStk->GetBotCall(true);
|
||||||
pClass->Lock(pProgBase); // locks the class
|
pClass->Lock(pProgBase); // locks the class
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -874,21 +874,21 @@ bool CBotFunction::CheckParam(CBotDefParam* pParam)
|
||||||
CBotDefParam* pp = m_Param;
|
CBotDefParam* pp = m_Param;
|
||||||
while ( pp != NULL && pParam != NULL )
|
while ( pp != NULL && pParam != NULL )
|
||||||
{
|
{
|
||||||
CBotTypResult type1 = pp->GivType();
|
CBotTypResult type1 = pp->GetType();
|
||||||
CBotTypResult type2 = pParam->GivType();
|
CBotTypResult type2 = pParam->GetType();
|
||||||
if ( !type1.Compare(type2) ) return false;
|
if ( !type1.Compare(type2) ) return false;
|
||||||
pp = pp->GivNext();
|
pp = pp->GetNext();
|
||||||
pParam = pParam->GivNext();
|
pParam = pParam->GetNext();
|
||||||
}
|
}
|
||||||
return ( pp == NULL && pParam == NULL );
|
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("()");
|
if ( m_Param == NULL ) return CBotString("()");
|
||||||
|
|
||||||
|
@ -897,8 +897,8 @@ CBotString CBotFunction::GivParams()
|
||||||
|
|
||||||
while (p != NULL)
|
while (p != NULL)
|
||||||
{
|
{
|
||||||
params += p->GivParamString();
|
params += p->GetParamString();
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
if ( p != NULL ) params += ", ";
|
if ( p != NULL ) params += ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -945,7 +945,7 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
// mainly not pStack->TokenStack here
|
// mainly not pStack->TokenStack here
|
||||||
// declared variables must remain visible thereafter
|
// declared variables must remain visible thereafter
|
||||||
|
|
||||||
pStack->SetStartError(p->GivStart());
|
pStack->SetStartError(p->GetStart());
|
||||||
|
|
||||||
if (IsOfType(p, ID_OPENPAR))
|
if (IsOfType(p, ID_OPENPAR))
|
||||||
{
|
{
|
||||||
|
@ -958,11 +958,11 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
else list->AddNext(param); // added to the list
|
else list->AddNext(param); // added to the list
|
||||||
|
|
||||||
CBotClass* pClass = NULL;//= CBotClass::Find(p);
|
CBotClass* pClass = NULL;//= CBotClass::Find(p);
|
||||||
param->m_typename = p->GivString();
|
param->m_typename = p->GetString();
|
||||||
CBotTypResult type = param->m_type = TypeParam(p, pStack);
|
CBotTypResult type = param->m_type = TypeParam(p, pStack);
|
||||||
// if ( type == CBotTypPointer ) type = CBotTypClass; // we must create a new object
|
// 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;
|
CBotToken* pp = p;
|
||||||
param->m_token = *p;
|
param->m_token = *p;
|
||||||
|
@ -977,17 +977,17 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( type.Eq(CBotTypArrayPointer) ) type.SetType(CBotTypArrayBody);
|
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);
|
// if ( pClass ) var->SetClass(pClass);
|
||||||
var->SetInit(2); // mark initialized
|
var->SetInit(2); // mark initialized
|
||||||
param->m_nIdent = CBotVar::NextUniqNum();
|
param->m_nIdent = CBotVar::NextUniqNum();
|
||||||
var->SetUniqNum(param->m_nIdent);
|
var->SetUniqNum(param->m_nIdent);
|
||||||
pStack->AddVar(var); // place on the stack
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
pStack->SetError(TX_CLOSEPAR, p->GivStart());
|
pStack->SetError(TX_CLOSEPAR, p->GetStart());
|
||||||
}
|
}
|
||||||
pStack->SetError(TX_NOTYP, p);
|
pStack->SetError(TX_NOTYP, p);
|
||||||
delete list;
|
delete list;
|
||||||
|
@ -995,7 +995,7 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
pStack->SetError(TX_OPENPAR, p->GivStart());
|
pStack->SetError(TX_OPENPAR, p->GetStart());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1016,24 +1016,24 @@ bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
|
||||||
while ( p != NULL )
|
while ( p != NULL )
|
||||||
{
|
{
|
||||||
// creates a local variable on the stack
|
// 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:
|
// serves to make the transformation of types:
|
||||||
if ( ppVars != NULL && ppVars[i] != NULL )
|
if ( ppVars != NULL && ppVars[i] != NULL )
|
||||||
{
|
{
|
||||||
switch (p->m_type.GivType())
|
switch (p->m_type.GetType())
|
||||||
{
|
{
|
||||||
case CBotTypInt:
|
case CBotTypInt:
|
||||||
newvar->SetValInt(ppVars[i]->GivValInt());
|
newvar->SetValInt(ppVars[i]->GetValInt());
|
||||||
break;
|
break;
|
||||||
case CBotTypFloat:
|
case CBotTypFloat:
|
||||||
newvar->SetValFloat(ppVars[i]->GivValFloat());
|
newvar->SetValFloat(ppVars[i]->GetValFloat());
|
||||||
break;
|
break;
|
||||||
case CBotTypString:
|
case CBotTypString:
|
||||||
newvar->SetValString(ppVars[i]->GivValString());
|
newvar->SetValString(ppVars[i]->GetValString());
|
||||||
break;
|
break;
|
||||||
case CBotTypBoolean:
|
case CBotTypBoolean:
|
||||||
newvar->SetValInt(ppVars[i]->GivValInt());
|
newvar->SetValInt(ppVars[i]->GetValInt());
|
||||||
break;
|
break;
|
||||||
case CBotTypIntrinsic:
|
case CBotTypIntrinsic:
|
||||||
((CBotVarClass*)newvar)->Copy(ppVars[i], false);
|
((CBotVarClass*)newvar)->Copy(ppVars[i], false);
|
||||||
|
@ -1041,7 +1041,7 @@ bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
|
||||||
case CBotTypPointer:
|
case CBotTypPointer:
|
||||||
case CBotTypArrayPointer:
|
case CBotTypArrayPointer:
|
||||||
{
|
{
|
||||||
newvar->SetPointer(ppVars[i]->GivPointer());
|
newvar->SetPointer(ppVars[i]->GetPointer());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1065,35 +1065,35 @@ void CBotDefParam::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
while ( p != NULL )
|
while ( p != NULL )
|
||||||
{
|
{
|
||||||
// creates a local variable on the stack
|
// 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);
|
var->SetUniqNum(p->m_nIdent);
|
||||||
p = p->m_next;
|
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;
|
return m_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotDefParam* CBotDefParam::GivNext()
|
CBotDefParam* CBotDefParam::GetNext()
|
||||||
{
|
{
|
||||||
return m_next;
|
return m_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotString CBotDefParam::GivParamString()
|
CBotString CBotDefParam::GetParamString()
|
||||||
{
|
{
|
||||||
CBotString param;
|
CBotString param;
|
||||||
|
|
||||||
param = m_typename;
|
param = m_typename;
|
||||||
param += ' ';
|
param += ' ';
|
||||||
|
|
||||||
param += m_token.GivString();
|
param += m_token.GetString();
|
||||||
return param;
|
return param;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1122,9 +1122,9 @@ CBotInstr* CBotReturn::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
CBotReturn* inst = new CBotReturn(); // creates the object
|
CBotReturn* inst = new CBotReturn(); // creates the object
|
||||||
inst->SetToken( pp );
|
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;
|
if ( IsOfType( p, ID_SEP ) ) return inst;
|
||||||
pStack->SetError( TX_BADTYPE, pp );
|
pStack->SetError( TX_BADTYPE, pp );
|
||||||
|
@ -1134,15 +1134,15 @@ CBotInstr* CBotReturn::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
inst->m_Instr = CBotExpression::Compile(p, pStack);
|
inst->m_Instr = CBotExpression::Compile(p, pStack);
|
||||||
if ( pStack->IsOk() )
|
if ( pStack->IsOk() )
|
||||||
{
|
{
|
||||||
CBotTypResult retType = pStack->GivTypResult(2);
|
CBotTypResult retType = pStack->GetTypResult(2);
|
||||||
if (TypeCompatible(retType, type, ID_ASS))
|
if (TypeCompatible(retType, type, ID_ASS))
|
||||||
{
|
{
|
||||||
if ( IsOfType( p, ID_SEP ) )
|
if ( IsOfType( p, ID_SEP ) )
|
||||||
return inst;
|
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;
|
delete inst;
|
||||||
|
@ -1154,7 +1154,7 @@ bool CBotReturn::Execute(CBotStack* &pj)
|
||||||
CBotStack* pile = pj->AddStack(this);
|
CBotStack* pile = pj->AddStack(this);
|
||||||
// if ( pile == EOX ) return true;
|
// 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
|
if ( m_Instr != NULL && !m_Instr->Execute(pile) ) return false; // evaluate the result
|
||||||
// the result is on the stack
|
// the result is on the stack
|
||||||
|
@ -1173,7 +1173,7 @@ void CBotReturn::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
CBotStack* pile = pj->RestoreStack(this);
|
CBotStack* pile = pj->RestoreStack(this);
|
||||||
if ( pile == NULL ) return;
|
if ( pile == NULL ) return;
|
||||||
|
|
||||||
if ( pile->GivState() == 0 )
|
if ( pile->GetState() == 0 )
|
||||||
{
|
{
|
||||||
if ( m_Instr != NULL ) m_Instr->RestoreState(pile, bMain); // evaluate the result
|
if ( m_Instr != NULL ) m_Instr->RestoreState(pile, bMain); // evaluate the result
|
||||||
return;
|
return;
|
||||||
|
@ -1202,9 +1202,9 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
CBotToken* pp = p;
|
CBotToken* pp = p;
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
|
|
||||||
pStack->SetStartError(p->GivStart());
|
pStack->SetStartError(p->GetStart());
|
||||||
CBotCStack* pile = pStack;
|
CBotCStack* pile = pStack;
|
||||||
|
|
||||||
if ( IsOfType(p, ID_OPENPAR) )
|
if ( IsOfType(p, ID_OPENPAR) )
|
||||||
|
@ -1216,11 +1216,11 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
// compile la list of parameters
|
// compile la list of parameters
|
||||||
if (!IsOfType(p, ID_CLOSEPAR)) while (true)
|
if (!IsOfType(p, ID_CLOSEPAR)) while (true)
|
||||||
{
|
{
|
||||||
start = p->GivStart();
|
start = p->GetStart();
|
||||||
pile = pile->TokenStack(); // keeps the results on the stack
|
pile = pile->TokenStack(); // keeps the results on the stack
|
||||||
|
|
||||||
CBotInstr* param = CBotExpression::Compile(p, pile);
|
CBotInstr* param = CBotExpression::Compile(p, pile);
|
||||||
end = p->GivStart();
|
end = p->GetStart();
|
||||||
if ( inst->m_Parameters == NULL ) inst->m_Parameters = param;
|
if ( inst->m_Parameters == NULL ) inst->m_Parameters = param;
|
||||||
else inst->m_Parameters->AddNext(param); // constructs the list
|
else inst->m_Parameters->AddNext(param); // constructs the list
|
||||||
|
|
||||||
|
@ -1232,22 +1232,22 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
|
||||||
if ( param != NULL )
|
if ( param != NULL )
|
||||||
{
|
{
|
||||||
if ( pile->GivTypResult().Eq(99) )
|
if ( pile->GetTypResult().Eq(99) )
|
||||||
{
|
{
|
||||||
delete pStack->TokenStack();
|
delete pStack->TokenStack();
|
||||||
pStack->SetError(TX_VOID, p->GivStart());
|
pStack->SetError(TX_VOID, p->GetStart());
|
||||||
delete inst;
|
delete inst;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ppVars[i] = pile->GivVar();
|
ppVars[i] = pile->GetVar();
|
||||||
ppVars[i]->GivToken()->SetPos(start, end);
|
ppVars[i]->GetToken()->SetPos(start, end);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (IsOfType(p, ID_COMMA)) continue; // skips the comma
|
if (IsOfType(p, ID_COMMA)) continue; // skips the comma
|
||||||
if (IsOfType(p, ID_CLOSEPAR)) break;
|
if (IsOfType(p, ID_CLOSEPAR)) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pStack->SetError(TX_CLOSEPAR, p->GivStart());
|
pStack->SetError(TX_CLOSEPAR, p->GetStart());
|
||||||
delete pStack->TokenStack();
|
delete pStack->TokenStack();
|
||||||
delete inst;
|
delete inst;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1257,17 +1257,17 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
// the routine is known?
|
// the routine is known?
|
||||||
// CBotClass* pClass = NULL;
|
// CBotClass* pClass = NULL;
|
||||||
inst->m_typRes = pStack->CompileCall(pp, ppVars, inst->m_nFuncIdent);
|
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();
|
// if (pVar2!=NULL) pp = pVar2->RetToken();
|
||||||
pStack->SetError( inst->m_typRes.GivType(), pp );
|
pStack->SetError( inst->m_typRes.GetType(), pp );
|
||||||
delete pStack->TokenStack();
|
delete pStack->TokenStack();
|
||||||
delete inst;
|
delete inst;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete pStack->TokenStack();
|
delete pStack->TokenStack();
|
||||||
if ( inst->m_typRes.GivType() > 0 )
|
if ( inst->m_typRes.GetType() > 0 )
|
||||||
{
|
{
|
||||||
CBotVar* pRes = CBotVar::Create("", inst->m_typRes);
|
CBotVar* pRes = CBotVar::Create("", inst->m_typRes);
|
||||||
pStack->SetVar(pRes); // for knowing the type of the result
|
pStack->SetVar(pRes); // for knowing the type of the result
|
||||||
|
@ -1298,13 +1298,13 @@ bool CBotInstrCall::Execute(CBotStack* &pj)
|
||||||
if ( p != NULL) while ( true )
|
if ( p != NULL) while ( true )
|
||||||
{
|
{
|
||||||
pile = pile->AddStack(); // place on the stack for the results
|
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?
|
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
|
pile->SetState(1); // mark as special for reknowed parameters \TODO marque spéciale pour reconnaîre parameters
|
||||||
}
|
}
|
||||||
ppVars[i++] = pile->GivVar();
|
ppVars[i++] = pile->GetVar();
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
if ( p == NULL) break;
|
if ( p == NULL) break;
|
||||||
}
|
}
|
||||||
ppVars[i] = NULL;
|
ppVars[i] = NULL;
|
||||||
|
@ -1312,7 +1312,7 @@ bool CBotInstrCall::Execute(CBotStack* &pj)
|
||||||
CBotStack* pile2 = pile->AddStack();
|
CBotStack* pile2 = pile->AddStack();
|
||||||
if ( pile2->IfStep() ) return false;
|
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
|
return pj->Return(pile2); // release the entire stack
|
||||||
}
|
}
|
||||||
|
@ -1336,13 +1336,13 @@ void CBotInstrCall::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
{
|
{
|
||||||
pile = pile->RestoreStack(); // place on the stack for the results
|
pile = pile->RestoreStack(); // place on the stack for the results
|
||||||
if ( pile == NULL ) return;
|
if ( pile == NULL ) return;
|
||||||
if ( pile->GivState() == 0 )
|
if ( pile->GetState() == 0 )
|
||||||
{
|
{
|
||||||
p->RestoreState(pile, bMain); // interrupt here!
|
p->RestoreState(pile, bMain); // interrupt here!
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ppVars[i++] = pile->GivVar(); // constructs the list of parameters
|
ppVars[i++] = pile->GetVar(); // constructs the list of parameters
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
if ( p == NULL) break;
|
if ( p == NULL) break;
|
||||||
}
|
}
|
||||||
ppVars[i] = NULL;
|
ppVars[i] = NULL;
|
||||||
|
@ -1350,7 +1350,7 @@ void CBotInstrCall::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
CBotStack* pile2 = pile->RestoreStack();
|
CBotStack* pile2 = pile->RestoreStack();
|
||||||
if ( pile2 == NULL ) return;
|
if ( pile2 == NULL ) return;
|
||||||
|
|
||||||
pile2->RestoreCall(m_nFuncIdent, GivToken(), ppVars);
|
pile2->RestoreCall(m_nFuncIdent, GetToken(), ppVars);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1369,7 +1369,7 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
|
||||||
if ( !IsOfType(p, ID_CLASS) ) return NULL;
|
if ( !IsOfType(p, ID_CLASS) ) return NULL;
|
||||||
|
|
||||||
CBotString name = p->GivString();
|
CBotString name = p->GetString();
|
||||||
|
|
||||||
CBotClass* pOld = CBotClass::Find(name);
|
CBotClass* pOld = CBotClass::Find(name);
|
||||||
if ( pOld != NULL && pOld->m_IsDef )
|
if ( pOld != NULL && pOld->m_IsDef )
|
||||||
|
@ -1384,7 +1384,7 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
|
||||||
CBotClass* pPapa = NULL;
|
CBotClass* pPapa = NULL;
|
||||||
if ( IsOfType( p, ID_EXTENDS ) )
|
if ( IsOfType( p, ID_EXTENDS ) )
|
||||||
{
|
{
|
||||||
CBotString name = p->GivString();
|
CBotString name = p->GetString();
|
||||||
pPapa = CBotClass::Find(name);
|
pPapa = CBotClass::Find(name);
|
||||||
|
|
||||||
if (!IsOfType(p, TokenTypVar) || pPapa == NULL )
|
if (!IsOfType(p, TokenTypVar) || pPapa == NULL )
|
||||||
|
@ -1454,7 +1454,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
||||||
{
|
{
|
||||||
CBotInstr* i = NULL;
|
CBotInstr* i = NULL;
|
||||||
|
|
||||||
if ( p->GivType() != ID_CLBRK )
|
if ( p->GetType() != ID_CLBRK )
|
||||||
i = CBotExpression::Compile( p, pStack ); // expression for the value
|
i = CBotExpression::Compile( p, pStack ); // expression for the value
|
||||||
else
|
else
|
||||||
i = new CBotEmpty(); // special if not a formula
|
i = new CBotEmpty(); // special if not a formula
|
||||||
|
@ -1463,14 +1463,14 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
||||||
|
|
||||||
if (!pStack->IsOk() || !IsOfType( p, ID_CLBRK ) )
|
if (!pStack->IsOk() || !IsOfType( p, ID_CLBRK ) )
|
||||||
{
|
{
|
||||||
pStack->SetError(TX_CLBRK, p->GivStart());
|
pStack->SetError(TX_CLBRK, p->GetStart());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CBotVar* pv = pStack->GivVar();
|
/* CBotVar* pv = pStack->GetVar();
|
||||||
if ( pv->GivType()>= CBotTypBoolean )
|
if ( pv->GetType()>= CBotTypBoolean )
|
||||||
{
|
{
|
||||||
pStack->SetError(TX_BADTYPE, p->GivStart());
|
pStack->SetError(TX_BADTYPE, p->GetStart());
|
||||||
return false;
|
return false;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
@ -1478,7 +1478,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
||||||
else limites->AddNext3(i);
|
else limites->AddNext3(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( p->GivType() == ID_OPENPAR )
|
if ( p->GetType() == ID_OPENPAR )
|
||||||
{
|
{
|
||||||
if ( !bSecond )
|
if ( !bSecond )
|
||||||
{
|
{
|
||||||
|
@ -1498,12 +1498,12 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
||||||
CBotFunction* prev = NULL;
|
CBotFunction* prev = NULL;
|
||||||
while ( pf != NULL )
|
while ( pf != NULL )
|
||||||
{
|
{
|
||||||
if (pf->GivName() == pp->GivString()) break;
|
if (pf->GetName() == pp->GetString()) break;
|
||||||
prev = pf;
|
prev = pf;
|
||||||
pf = pf->Next();
|
pf = pf->Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bConstructor = (pp->GivString() == GivName());
|
bool bConstructor = (pp->GetString() == GetName());
|
||||||
CBotCStack* pile = pStack->TokenStack(NULL, true);
|
CBotCStack* pile = pStack->TokenStack(NULL, true);
|
||||||
|
|
||||||
// make "this" known
|
// make "this" known
|
||||||
|
@ -1531,9 +1531,9 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
||||||
{
|
{
|
||||||
CBotVar* pcopy = CBotVar::Create(pv);
|
CBotVar* pcopy = CBotVar::Create(pv);
|
||||||
pcopy->SetInit(!bConstructor || pv->IsStatic());
|
pcopy->SetInit(!bConstructor || pv->IsStatic());
|
||||||
pcopy->SetUniqNum(pv->GivUniqNum());
|
pcopy->SetUniqNum(pv->GetUniqNum());
|
||||||
pile->AddVar(pcopy);
|
pile->AddVar(pcopy);
|
||||||
pv = pv->GivNext();
|
pv = pv->GetNext();
|
||||||
}
|
}
|
||||||
my = my->m_pParent;
|
my = my->m_pParent;
|
||||||
}
|
}
|
||||||
|
@ -1545,7 +1545,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
||||||
|
|
||||||
if ( f != NULL )
|
if ( f != NULL )
|
||||||
{
|
{
|
||||||
f->m_pProg = pStack->GivBotCall();
|
f->m_pProg = pStack->GetBotCall();
|
||||||
f->m_bSynchro = bSynchro;
|
f->m_bSynchro = bSynchro;
|
||||||
// replaces the element in the chain
|
// replaces the element in the chain
|
||||||
f->m_next = pf->m_next;
|
f->m_next = pf->m_next;
|
||||||
|
@ -1572,7 +1572,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
||||||
{
|
{
|
||||||
if ( type.Eq(CBotTypArrayPointer) )
|
if ( type.Eq(CBotTypArrayPointer) )
|
||||||
{
|
{
|
||||||
i = CBotListArray::Compile(p, pStack, type.GivTypElem());
|
i = CBotListArray::Compile(p, pStack, type.GetTypElem());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1585,7 +1585,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
||||||
|
|
||||||
if ( !bSecond )
|
if ( !bSecond )
|
||||||
{
|
{
|
||||||
CBotVar* pv = CBotVar::Create(pp->GivString(), type);
|
CBotVar* pv = CBotVar::Create(pp->GetString(), type);
|
||||||
pv -> SetStatic( bStatic );
|
pv -> SetStatic( bStatic );
|
||||||
pv -> SetPrivate( mProtect );
|
pv -> SetPrivate( mProtect );
|
||||||
|
|
||||||
|
@ -1599,7 +1599,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
||||||
{
|
{
|
||||||
CBotStack* pile = CBotStack::FirstStack(); // independent stack
|
CBotStack* pile = CBotStack::FirstStack(); // independent stack
|
||||||
while(pile->IsOk() && !pv->m_InitExpr->Execute(pile)); // evaluates the expression without timer
|
while(pile->IsOk() && !pv->m_InitExpr->Execute(pile)); // evaluates the expression without timer
|
||||||
pv->SetVal( pile->GivVar() ) ;
|
pv->SetVal( pile->GetVar() ) ;
|
||||||
pile->Delete();
|
pile->Delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1620,7 +1620,7 @@ CBotClass* CBotClass::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
if ( !IsOfType(p, ID_PUBLIC) ) return NULL;
|
if ( !IsOfType(p, ID_PUBLIC) ) return NULL;
|
||||||
if ( !IsOfType(p, ID_CLASS) ) return NULL;
|
if ( !IsOfType(p, ID_CLASS) ) return NULL;
|
||||||
|
|
||||||
CBotString name = p->GivString();
|
CBotString name = p->GetString();
|
||||||
|
|
||||||
// a name for the class is there?
|
// a name for the class is there?
|
||||||
if (IsOfType(p, TokenTypVar))
|
if (IsOfType(p, TokenTypVar))
|
||||||
|
|
|
@ -95,7 +95,7 @@ bool CBotIf :: Execute(CBotStack* &pj)
|
||||||
if ( pile->IfStep() ) return false;
|
if ( pile->IfStep() ) return false;
|
||||||
|
|
||||||
// according to recovery, it may be in one of two states
|
// according to recovery, it may be in one of two states
|
||||||
if( pile->GivState() == 0 )
|
if( pile->GetState() == 0 )
|
||||||
{
|
{
|
||||||
// evaluates the condition
|
// evaluates the condition
|
||||||
if ( !m_Condition->Execute(pile) ) return false; // interrupted here?
|
if ( !m_Condition->Execute(pile) ) return false; // interrupted here?
|
||||||
|
@ -113,7 +113,7 @@ bool CBotIf :: Execute(CBotStack* &pj)
|
||||||
// second state, evaluates the associated instructions
|
// second state, evaluates the associated instructions
|
||||||
// the result of the condition is on the stack
|
// 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
|
if ( m_Block != NULL && // block may be absent
|
||||||
!m_Block->Execute(pile) ) return false; // interrupted here?
|
!m_Block->Execute(pile) ) return false; // interrupted here?
|
||||||
|
@ -137,7 +137,7 @@ void CBotIf :: RestoreState(CBotStack* &pj, bool bMain)
|
||||||
if ( pile == NULL ) return;
|
if ( pile == NULL ) return;
|
||||||
|
|
||||||
// according to recovery, it may be in one of two states
|
// according to recovery, it may be in one of two states
|
||||||
if( pile->GivState() == 0 )
|
if( pile->GetState() == 0 )
|
||||||
{
|
{
|
||||||
// evaluates the condition
|
// evaluates the condition
|
||||||
m_Condition->RestoreState(pile, bMain); // interrupted here!
|
m_Condition->RestoreState(pile, bMain); // interrupted here!
|
||||||
|
@ -147,7 +147,7 @@ void CBotIf :: RestoreState(CBotStack* &pj, bool bMain)
|
||||||
// second state, evaluates the associated instructions
|
// second state, evaluates the associated instructions
|
||||||
// the result of the condition is on the stack
|
// 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
|
if ( m_Block != NULL ) // block may be absent
|
||||||
m_Block->RestoreState(pile, bMain); // interrupted here!
|
m_Block->RestoreState(pile, bMain); // interrupted here!
|
||||||
|
|
|
@ -87,18 +87,18 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
|
||||||
|
|
||||||
|
|
||||||
CBotCStack* pStack = new CBotCStack(NULL);
|
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
|
pStack->SetBotCall(this); // defined used routines
|
||||||
CBotCall::SetPUser(pUser);
|
CBotCall::SetPUser(pUser);
|
||||||
|
|
||||||
// first made a quick pass just to take the headers of routines and classes
|
// 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 ( IsOfType(p, ID_SEP) ) continue; // semicolons lurking
|
||||||
|
|
||||||
if ( p->GivType() == ID_CLASS ||
|
if ( p->GetType() == ID_CLASS ||
|
||||||
( p->GivType() == ID_PUBLIC && p->GivNext()->GivType() == ID_CLASS ))
|
( p->GetType() == ID_PUBLIC && p->GetNext()->GetType() == ID_CLASS ))
|
||||||
{
|
{
|
||||||
CBotClass* nxt = CBotClass::Compile1(p, pStack);
|
CBotClass* nxt = CBotClass::Compile1(p, pStack);
|
||||||
if (m_pClass == NULL ) m_pClass = nxt;
|
if (m_pClass == NULL ) m_pClass = nxt;
|
||||||
|
@ -113,7 +113,7 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
|
||||||
}
|
}
|
||||||
if ( !pStack->IsOk() )
|
if ( !pStack->IsOk() )
|
||||||
{
|
{
|
||||||
m_ErrorCode = pStack->GivError(m_ErrorStart, m_ErrorEnd);
|
m_ErrorCode = pStack->GetError(m_ErrorStart, m_ErrorEnd);
|
||||||
delete m_Prog;
|
delete m_Prog;
|
||||||
m_Prog = NULL;
|
m_Prog = NULL;
|
||||||
delete pBaseToken;
|
delete pBaseToken;
|
||||||
|
@ -123,14 +123,14 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
|
||||||
// CBotFunction* temp = NULL;
|
// CBotFunction* temp = NULL;
|
||||||
CBotFunction* next = m_Prog; // rewind the list
|
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 ( IsOfType(p, ID_SEP) ) continue; // semicolons lurking
|
||||||
|
|
||||||
if ( p->GivType() == ID_CLASS ||
|
if ( p->GetType() == ID_CLASS ||
|
||||||
( p->GivType() == ID_PUBLIC && p->GivNext()->GivType() == ID_CLASS ))
|
( p->GetType() == ID_PUBLIC && p->GetNext()->GetType() == ID_CLASS ))
|
||||||
{
|
{
|
||||||
m_bCompileClass = true;
|
m_bCompileClass = true;
|
||||||
CBotClass::Compile(p, pStack); // completes the definition of the class
|
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;
|
m_bCompileClass = false;
|
||||||
CBotFunction::Compile(p, pStack, next);
|
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->m_pProg = this; // keeps pointers to the module
|
||||||
next = next->Next();
|
next = next->Next();
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
|
||||||
|
|
||||||
if ( !pStack->IsOk() )
|
if ( !pStack->IsOk() )
|
||||||
{
|
{
|
||||||
m_ErrorCode = pStack->GivError(m_ErrorStart, m_ErrorEnd);
|
m_ErrorCode = pStack->GetError(m_ErrorStart, m_ErrorEnd);
|
||||||
delete m_Prog;
|
delete m_Prog;
|
||||||
m_Prog = NULL;
|
m_Prog = NULL;
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ bool CBotProgram::Start(const char* name)
|
||||||
m_pRun = m_Prog;
|
m_pRun = m_Prog;
|
||||||
while (m_pRun != NULL)
|
while (m_pRun != NULL)
|
||||||
{
|
{
|
||||||
if ( m_pRun->GivName() == name ) break;
|
if ( m_pRun->GetName() == name ) break;
|
||||||
m_pRun = m_pRun->m_next;
|
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;
|
CBotFunction* p = m_Prog;
|
||||||
while (p != NULL)
|
while (p != NULL)
|
||||||
{
|
{
|
||||||
if ( p->GivName() == name ) break;
|
if ( p->GetName() == name ) break;
|
||||||
p = p->m_next;
|
p = p->m_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ bool CBotProgram::Run(void* pUser, int timer)
|
||||||
// completed on a mistake?
|
// completed on a mistake?
|
||||||
if (!ok && !m_pStack->IsOk())
|
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
|
#if STACKMEM
|
||||||
m_pStack->Delete();
|
m_pStack->Delete();
|
||||||
#else
|
#else
|
||||||
|
@ -289,12 +289,12 @@ bool CBotProgram::GetRunPos(const char* &FunctionName, int &start, int &end)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotVar* CBotProgram::GivStackVars(const char* &FunctionName, int level)
|
CBotVar* CBotProgram::GetStackVars(const char* &FunctionName, int level)
|
||||||
{
|
{
|
||||||
FunctionName = NULL;
|
FunctionName = NULL;
|
||||||
if (m_pStack == NULL) return NULL;
|
if (m_pStack == NULL) return NULL;
|
||||||
|
|
||||||
return m_pStack->GivStackVars(FunctionName, level);
|
return m_pStack->GetStackVars(FunctionName, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBotProgram::SetTimer(int n)
|
void CBotProgram::SetTimer(int n)
|
||||||
|
@ -302,7 +302,7 @@ void CBotProgram::SetTimer(int n)
|
||||||
CBotStack::SetTimer( n );
|
CBotStack::SetTimer( n );
|
||||||
}
|
}
|
||||||
|
|
||||||
int CBotProgram::GivError()
|
int CBotProgram::GetError()
|
||||||
{
|
{
|
||||||
return m_ErrorCode;
|
return m_ErrorCode;
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ void CBotProgram::SetIdent(long n)
|
||||||
m_Ident = n;
|
m_Ident = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
long CBotProgram::GivIdent()
|
long CBotProgram::GetIdent()
|
||||||
{
|
{
|
||||||
return m_Ident;
|
return m_Ident;
|
||||||
}
|
}
|
||||||
|
@ -334,7 +334,7 @@ bool CBotProgram::GetError(int& code, int& start, int& end, CBotProgram* &pProg)
|
||||||
return code > 0;
|
return code > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotString CBotProgram::GivErrorText(int code)
|
CBotString CBotProgram::GetErrorText(int code)
|
||||||
{
|
{
|
||||||
CBotString TextError;
|
CBotString TextError;
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ CBotString CBotProgram::GivErrorText(int code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CBotFunction* CBotProgram::GivFunctions()
|
CBotFunction* CBotProgram::GetFunctions()
|
||||||
{
|
{
|
||||||
return m_Prog;
|
return m_Prog;
|
||||||
}
|
}
|
||||||
|
@ -421,7 +421,7 @@ bool WriteString(FILE* pf, CBotString s)
|
||||||
{
|
{
|
||||||
size_t lg1, lg2;
|
size_t lg1, lg2;
|
||||||
|
|
||||||
lg1 = s.GivLength();
|
lg1 = s.GetLength();
|
||||||
if (!WriteWord(pf, lg1)) return false;
|
if (!WriteWord(pf, lg1)) return false;
|
||||||
|
|
||||||
lg2 = fwrite(s, 1, lg1, pf );
|
lg2 = fwrite(s, 1, lg1, pf );
|
||||||
|
@ -445,19 +445,19 @@ bool ReadString(FILE* pf, CBotString& s)
|
||||||
|
|
||||||
bool WriteType(FILE* pf, CBotTypResult type)
|
bool WriteType(FILE* pf, CBotTypResult type)
|
||||||
{
|
{
|
||||||
int typ = type.GivType();
|
int typ = type.GetType();
|
||||||
if ( typ == CBotTypIntrinsic ) typ = CBotTypClass;
|
if ( typ == CBotTypIntrinsic ) typ = CBotTypClass;
|
||||||
if ( !WriteWord(pf, typ) ) return false;
|
if ( !WriteWord(pf, typ) ) return false;
|
||||||
if ( typ == CBotTypClass )
|
if ( typ == CBotTypClass )
|
||||||
{
|
{
|
||||||
CBotClass* p = type.GivClass();
|
CBotClass* p = type.GetClass();
|
||||||
if ( !WriteString(pf, p->GivName()) ) return false;
|
if ( !WriteString(pf, p->GetName()) ) return false;
|
||||||
}
|
}
|
||||||
if ( type.Eq( CBotTypArrayBody ) ||
|
if ( type.Eq( CBotTypArrayBody ) ||
|
||||||
type.Eq( CBotTypArrayPointer ) )
|
type.Eq( CBotTypArrayPointer ) )
|
||||||
{
|
{
|
||||||
if ( !WriteWord(pf, type.GivLimite()) ) return false;
|
if ( !WriteWord(pf, type.GetLimite()) ) return false;
|
||||||
if ( !WriteType(pf, type.GivTypElem()) ) return false;
|
if ( !WriteType(pf, type.GetTypElem()) ) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -507,7 +507,7 @@ bool CBotProgram::SaveState(FILE* pf)
|
||||||
if ( m_pStack != NULL )
|
if ( m_pStack != NULL )
|
||||||
{
|
{
|
||||||
if (!WriteWord( pf, 1)) return false;
|
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;
|
if (!m_pStack->SaveState(pf)) return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -551,7 +551,7 @@ bool CBotProgram::RestoreState(FILE* pf)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CBotProgram::GivVersion()
|
int CBotProgram::GetVersion()
|
||||||
{
|
{
|
||||||
return CBOTVERSION;
|
return CBOTVERSION;
|
||||||
}
|
}
|
||||||
|
@ -592,7 +592,7 @@ bool CBotCall::AddFunction(const char* name,
|
||||||
|
|
||||||
if ( p != NULL ) while ( p->m_next != NULL )
|
if ( p != NULL ) while ( p->m_next != NULL )
|
||||||
{
|
{
|
||||||
if ( p->GivName() == name )
|
if ( p->GetName() == name )
|
||||||
{
|
{
|
||||||
// frees redefined function
|
// frees redefined function
|
||||||
if ( pp ) pp->m_next = p->m_next;
|
if ( pp ) pp->m_next = p->m_next;
|
||||||
|
@ -631,8 +631,8 @@ CBotVar* MakeListVars(CBotVar** ppVars, bool bSetVal=false)
|
||||||
CBotVar* pp = CBotVar::Create(ppVars[i]);
|
CBotVar* pp = CBotVar::Create(ppVars[i]);
|
||||||
if (bSetVal) pp->Copy(ppVars[i]);
|
if (bSetVal) pp->Copy(ppVars[i]);
|
||||||
else
|
else
|
||||||
if ( ppVars[i]->GivType() == CBotTypPointer )
|
if ( ppVars[i]->GetType() == CBotTypPointer )
|
||||||
pp->SetClass( ppVars[i]->GivClass());
|
pp->SetClass( ppVars[i]->GetClass());
|
||||||
// copy the pointer according to indirections
|
// copy the pointer according to indirections
|
||||||
if (pVar == NULL) pVar = pp;
|
if (pVar == NULL) pVar = pp;
|
||||||
else pVar->AddNext(pp);
|
else pVar->AddNext(pp);
|
||||||
|
@ -648,7 +648,7 @@ CBotTypResult CBotCall::CompileCall(CBotToken* &p, CBotVar** ppVar, CBotCStack*
|
||||||
{
|
{
|
||||||
nIdent = 0;
|
nIdent = 0;
|
||||||
CBotCall* pt = m_ListCalls;
|
CBotCall* pt = m_ListCalls;
|
||||||
CBotString name = p->GivString();
|
CBotString name = p->GetString();
|
||||||
|
|
||||||
while ( pt != NULL )
|
while ( pt != NULL )
|
||||||
{
|
{
|
||||||
|
@ -657,14 +657,14 @@ CBotTypResult CBotCall::CompileCall(CBotToken* &p, CBotVar** ppVar, CBotCStack*
|
||||||
CBotVar* pVar = MakeListVars(ppVar);
|
CBotVar* pVar = MakeListVars(ppVar);
|
||||||
CBotVar* pVar2 = pVar;
|
CBotVar* pVar2 = pVar;
|
||||||
CBotTypResult r = pt->m_rComp(pVar2, m_pUser);
|
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 a class is returned, it is actually a pointer
|
||||||
if ( ret == CBotTypClass ) r.SetType( ret = CBotTypPointer );
|
if ( ret == CBotTypClass ) r.SetType( ret = CBotTypPointer );
|
||||||
|
|
||||||
if ( ret > 20 )
|
if ( ret > 20 )
|
||||||
{
|
{
|
||||||
if (pVar2) pStack->SetError(ret, p /*pVar2->GivToken()*/ );
|
if (pVar2) pStack->SetError(ret, p /*pVar2->GetToken()*/ );
|
||||||
}
|
}
|
||||||
delete pVar;
|
delete pVar;
|
||||||
nIdent = pt->m_nFuncIdent;
|
nIdent = pt->m_nFuncIdent;
|
||||||
|
@ -688,7 +688,7 @@ bool CBotCall::CheckCall(const char* name)
|
||||||
|
|
||||||
while ( p != NULL )
|
while ( p != NULL )
|
||||||
{
|
{
|
||||||
if ( name == p->GivName() ) return true;
|
if ( name == p->GetName() ) return true;
|
||||||
p = p->m_next;
|
p = p->m_next;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -696,7 +696,7 @@ bool CBotCall::CheckCall(const char* name)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CBotString CBotCall::GivName()
|
CBotString CBotCall::GetName()
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
@ -724,7 +724,7 @@ int CBotCall::DoCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotStack*
|
||||||
|
|
||||||
if ( token != NULL )
|
if ( token != NULL )
|
||||||
{
|
{
|
||||||
CBotString name = token->GivString();
|
CBotString name = token->GetString();
|
||||||
while ( pt != NULL )
|
while ( pt != NULL )
|
||||||
{
|
{
|
||||||
if ( pt->m_name == name )
|
if ( pt->m_name == name )
|
||||||
|
@ -750,7 +750,7 @@ fund:
|
||||||
|
|
||||||
CBotVar* pRes = pResult;
|
CBotVar* pRes = pResult;
|
||||||
int Exception = 0;
|
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
|
if ( pResult != pRes ) delete pRes; // different result if made
|
||||||
delete pVarToDelete;
|
delete pVarToDelete;
|
||||||
|
@ -766,7 +766,7 @@ fund:
|
||||||
}
|
}
|
||||||
pStack->SetVar(pResult);
|
pStack->SetVar(pResult);
|
||||||
|
|
||||||
if ( rettype.GivType() > 0 && pResult == NULL )
|
if ( rettype.GetType() > 0 && pResult == NULL )
|
||||||
{
|
{
|
||||||
pStack->SetError(TX_NORETVAL, token);
|
pStack->SetError(TX_NORETVAL, token);
|
||||||
}
|
}
|
||||||
|
@ -805,7 +805,7 @@ bool CBotCall::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBot
|
||||||
CBotCall* pt = m_ListCalls;
|
CBotCall* pt = m_ListCalls;
|
||||||
|
|
||||||
{
|
{
|
||||||
CBotString name = token->GivString();
|
CBotString name = token->GetString();
|
||||||
while ( pt != NULL )
|
while ( pt != NULL )
|
||||||
{
|
{
|
||||||
if ( pt->m_name == name )
|
if ( pt->m_name == name )
|
||||||
|
@ -829,14 +829,14 @@ bool CBotCall::Run(CBotStack* pStack)
|
||||||
{
|
{
|
||||||
CBotStack* pile = pStack->AddStackEOX(this);
|
CBotStack* pile = pStack->AddStackEOX(this);
|
||||||
if ( pile == EOX ) return true;
|
if ( pile == EOX ) return true;
|
||||||
CBotVar* pVar = pile->GivVar();
|
CBotVar* pVar = pile->GetVar();
|
||||||
|
|
||||||
CBotStack* pile2 = pile->AddStack();
|
CBotStack* pile2 = pile->AddStack();
|
||||||
CBotVar* pResult = pile2->GivVar();
|
CBotVar* pResult = pile2->GetVar();
|
||||||
CBotVar* pRes = pResult;
|
CBotVar* pRes = pResult;
|
||||||
|
|
||||||
int Exception = 0;
|
int Exception = 0;
|
||||||
int res = m_rExec(pVar, pResult, Exception, pStack->GivPUser());
|
int res = m_rExec(pVar, pResult, Exception, pStack->GetPUser());
|
||||||
|
|
||||||
if (res == false)
|
if (res == false)
|
||||||
{
|
{
|
||||||
|
@ -892,10 +892,10 @@ CBotTypResult CBotCallMethode::CompileCall(const char* name, CBotVar* pThis,
|
||||||
CBotVar* pVar = MakeListVars(ppVar, true);
|
CBotVar* pVar = MakeListVars(ppVar, true);
|
||||||
CBotVar* pVar2 = pVar;
|
CBotVar* pVar2 = pVar;
|
||||||
CBotTypResult r = pt->m_rComp(pThis, pVar2);
|
CBotTypResult r = pt->m_rComp(pThis, pVar2);
|
||||||
int ret = r.GivType();
|
int ret = r.GetType();
|
||||||
if ( ret > 20 )
|
if ( ret > 20 )
|
||||||
{
|
{
|
||||||
if (pVar2) pStack->SetError(ret, pVar2->GivToken());
|
if (pVar2) pStack->SetError(ret, pVar2->GetToken());
|
||||||
}
|
}
|
||||||
delete pVar;
|
delete pVar;
|
||||||
nIdent = pt->m_nFuncIdent;
|
nIdent = pt->m_nFuncIdent;
|
||||||
|
@ -907,7 +907,7 @@ CBotTypResult CBotCallMethode::CompileCall(const char* name, CBotVar* pThis,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CBotString CBotCallMethode::GivName()
|
CBotString CBotCallMethode::GetName()
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
@ -951,7 +951,7 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
|
||||||
{
|
{
|
||||||
if (Exception!=0)
|
if (Exception!=0)
|
||||||
{
|
{
|
||||||
// pStack->SetError(Exception, pVar->GivToken());
|
// pStack->SetError(Exception, pVar->GetToken());
|
||||||
pStack->SetError(Exception, pToken);
|
pStack->SetError(Exception, pToken);
|
||||||
}
|
}
|
||||||
delete pVarToDelete;
|
delete pVarToDelete;
|
||||||
|
@ -982,7 +982,7 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
|
||||||
{
|
{
|
||||||
if (Exception!=0)
|
if (Exception!=0)
|
||||||
{
|
{
|
||||||
// pStack->SetError(Exception, pVar->GivToken());
|
// pStack->SetError(Exception, pVar->GetToken());
|
||||||
pStack->SetError(Exception, pToken);
|
pStack->SetError(Exception, pToken);
|
||||||
}
|
}
|
||||||
delete pVarToDelete;
|
delete pVarToDelete;
|
||||||
|
@ -1003,12 +1003,12 @@ bool rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||||
if ( pVar == NULL ) return TX_LOWPARAM;
|
if ( pVar == NULL ) return TX_LOWPARAM;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
pVar = pVar->GivItemList();
|
pVar = pVar->GetItemList();
|
||||||
|
|
||||||
while ( pVar != NULL )
|
while ( pVar != NULL )
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
pResult->SetValInt(i);
|
pResult->SetValInt(i);
|
||||||
|
@ -1018,7 +1018,7 @@ bool rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||||
CBotTypResult cSizeOf( CBotVar* &pVar, void* pUser )
|
CBotTypResult cSizeOf( CBotVar* &pVar, void* pUser )
|
||||||
{
|
{
|
||||||
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
||||||
if ( pVar->GivType() != CBotTypArrayPointer )
|
if ( pVar->GetType() != CBotTypArrayPointer )
|
||||||
return CBotTypResult( TX_BADPARAM );
|
return CBotTypResult( TX_BADPARAM );
|
||||||
return CBotTypResult( CBotTypInt );
|
return CBotTypResult( CBotTypInt );
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,7 @@ CBotStack* CBotStack::AddStack2(bool bBlock)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBotStack::GivBlock()
|
bool CBotStack::GetBlock()
|
||||||
{
|
{
|
||||||
return m_bBlock;
|
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
|
// gives on the stack value calculated by the last CBotReturn
|
||||||
|
|
||||||
bool CBotStack::GivRetVar(bool bRet)
|
bool CBotStack::GetRetVar(bool bRet)
|
||||||
{
|
{
|
||||||
if (m_error == -3)
|
if (m_error == -3)
|
||||||
{
|
{
|
||||||
|
@ -441,7 +441,7 @@ bool CBotStack::GivRetVar(bool bRet)
|
||||||
return bRet; // interrupted by something other than return
|
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;
|
start = m_start;
|
||||||
end = m_end;
|
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;
|
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;
|
if (m_var == NULL) return -1;
|
||||||
return m_var->GivTypResult(mode);
|
return m_var->GetTypResult(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBotStack::SetType(CBotTypResult& type)
|
void CBotStack::SetType(CBotTypResult& type)
|
||||||
|
@ -471,14 +471,14 @@ void CBotStack::SetType(CBotTypResult& type)
|
||||||
CBotVar* CBotStack::FindVar(CBotToken* &pToken, bool bUpdate, bool bModif)
|
CBotVar* CBotStack::FindVar(CBotToken* &pToken, bool bUpdate, bool bModif)
|
||||||
{
|
{
|
||||||
CBotStack* p = this;
|
CBotStack* p = this;
|
||||||
CBotString name = pToken->GivString();
|
CBotString name = pToken->GetString();
|
||||||
|
|
||||||
while (p != NULL)
|
while (p != NULL)
|
||||||
{
|
{
|
||||||
CBotVar* pp = p->m_listVar;
|
CBotVar* pp = p->m_listVar;
|
||||||
while ( pp != NULL)
|
while ( pp != NULL)
|
||||||
{
|
{
|
||||||
if (pp->GivName() == name)
|
if (pp->GetName() == name)
|
||||||
{
|
{
|
||||||
if ( bUpdate )
|
if ( bUpdate )
|
||||||
pp->Maj(m_pUser, false);
|
pp->Maj(m_pUser, false);
|
||||||
|
@ -500,7 +500,7 @@ CBotVar* CBotStack::FindVar(const char* name)
|
||||||
CBotVar* pp = p->m_listVar;
|
CBotVar* pp = p->m_listVar;
|
||||||
while ( pp != NULL)
|
while ( pp != NULL)
|
||||||
{
|
{
|
||||||
if (pp->GivName() == name)
|
if (pp->GetName() == name)
|
||||||
{
|
{
|
||||||
return pp;
|
return pp;
|
||||||
}
|
}
|
||||||
|
@ -519,7 +519,7 @@ CBotVar* CBotStack::FindVar(long ident, bool bUpdate, bool bModif)
|
||||||
CBotVar* pp = p->m_listVar;
|
CBotVar* pp = p->m_listVar;
|
||||||
while ( pp != NULL)
|
while ( pp != NULL)
|
||||||
{
|
{
|
||||||
if (pp->GivUniqNum() == ident)
|
if (pp->GetUniqNum() == ident)
|
||||||
{
|
{
|
||||||
if ( bUpdate )
|
if ( bUpdate )
|
||||||
pp->Maj(m_pUser, false);
|
pp->Maj(m_pUser, false);
|
||||||
|
@ -576,8 +576,8 @@ void CBotStack::SetError(int n, CBotToken* token)
|
||||||
m_error = n;
|
m_error = n;
|
||||||
if (token != NULL)
|
if (token != NULL)
|
||||||
{
|
{
|
||||||
m_start = token->GivStart();
|
m_start = token->GetStart();
|
||||||
m_end = token->GivEnd();
|
m_end = token->GetEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,8 +590,8 @@ void CBotStack::ResetError(int n, int start, int end)
|
||||||
|
|
||||||
void CBotStack::SetPosError(CBotToken* token)
|
void CBotStack::SetPosError(CBotToken* token)
|
||||||
{
|
{
|
||||||
m_start = token->GivStart();
|
m_start = token->GetStart();
|
||||||
m_end = token->GivEnd();
|
m_end = token->GetEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBotStack::SetTimer(int n)
|
void CBotStack::SetTimer(int n)
|
||||||
|
@ -643,34 +643,34 @@ void CBotStack::SetCopyVar( CBotVar* var )
|
||||||
{
|
{
|
||||||
if (m_var) delete m_var; // replacement of a variable
|
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 );
|
m_var->Copy( var );
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotVar* CBotStack::GivVar()
|
CBotVar* CBotStack::GetVar()
|
||||||
{
|
{
|
||||||
return m_var;
|
return m_var;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotVar* CBotStack::GivPtVar()
|
CBotVar* CBotStack::GetPtVar()
|
||||||
{
|
{
|
||||||
CBotVar* p = m_var;
|
CBotVar* p = m_var;
|
||||||
m_var = NULL; // therefore will not be destroyed
|
m_var = NULL; // therefore will not be destroyed
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotVar* CBotStack::GivCopyVar()
|
CBotVar* CBotStack::GetCopyVar()
|
||||||
{
|
{
|
||||||
if (m_var == NULL) return NULL;
|
if (m_var == NULL) return NULL;
|
||||||
CBotVar* v = CBotVar::Create("", m_var->GivType());
|
CBotVar* v = CBotVar::Create("", m_var->GetType());
|
||||||
v->Copy( m_var );
|
v->Copy( m_var );
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
long CBotStack::GivVal()
|
long CBotStack::GetVal()
|
||||||
{
|
{
|
||||||
if (m_var == NULL) return 0;
|
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
|
*pp = pVar; // added after
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if ( pVar->GivUniqNum() == 0 ) ASM_TRAP();
|
if ( pVar->GetUniqNum() == 0 ) ASM_TRAP();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,7 +710,7 @@ void CBotStack::SetBotCall(CBotProgram* p)
|
||||||
m_bFunc = true;
|
m_bFunc = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotProgram* CBotStack::GivBotCall(bool bFirst)
|
CBotProgram* CBotStack::GetBotCall(bool bFirst)
|
||||||
{
|
{
|
||||||
if ( ! bFirst ) return m_prog;
|
if ( ! bFirst ) return m_prog;
|
||||||
CBotStack* p = this;
|
CBotStack* p = this;
|
||||||
|
@ -718,7 +718,7 @@ CBotProgram* CBotStack::GivBotCall(bool bFirst)
|
||||||
return p->m_prog;
|
return p->m_prog;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* CBotStack::GivPUser()
|
void* CBotStack::GetPUser()
|
||||||
{
|
{
|
||||||
return m_pUser;
|
return m_pUser;
|
||||||
}
|
}
|
||||||
|
@ -731,19 +731,19 @@ bool CBotStack::ExecuteCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBo
|
||||||
// first looks by the identifier
|
// first looks by the identifier
|
||||||
|
|
||||||
res = CBotCall::DoCall(nIdent, NULL, ppVar, this, rettype );
|
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 );
|
res = m_prog->GetFunctions()->DoCall(nIdent, NULL, ppVar, this, token );
|
||||||
if (res.GivType() >= 0) return res.GivType();
|
if (res.GetType() >= 0) return res.GetType();
|
||||||
|
|
||||||
// if not found (recompile?) seeks by name
|
// if not found (recompile?) seeks by name
|
||||||
|
|
||||||
nIdent = 0;
|
nIdent = 0;
|
||||||
res = CBotCall::DoCall(nIdent, token, ppVar, this, rettype );
|
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 );
|
res = m_prog->GetFunctions()->DoCall(nIdent, token->GetString(), ppVar, this, token );
|
||||||
if (res.GivType() >= 0) return res.GivType();
|
if (res.GetType() >= 0) return res.GetType();
|
||||||
|
|
||||||
SetError(TX_NOCALL, token);
|
SetError(TX_NOCALL, token);
|
||||||
return true;
|
return true;
|
||||||
|
@ -754,7 +754,7 @@ void CBotStack::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar)
|
||||||
if ( m_next == NULL ) return;
|
if ( m_next == NULL ) return;
|
||||||
|
|
||||||
if ( !CBotCall::RestoreCall(nIdent, token, ppVar, this) )
|
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->Save0State(pf)) return false; // common header
|
||||||
if ( !pVar->Save1State(pf) ) return false; // saves as the child class
|
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;
|
if ( funct == NULL ) return;
|
||||||
|
|
||||||
CBotToken* t = funct->GivToken();
|
CBotToken* t = funct->GetToken();
|
||||||
FunctionName = t->GivString();
|
FunctionName = t->GetString();
|
||||||
|
|
||||||
// if ( p->m_instr != NULL ) instr = p->m_instr;
|
// if ( p->m_instr != NULL ) instr = p->m_instr;
|
||||||
|
|
||||||
t = instr->GivToken();
|
t = instr->GetToken();
|
||||||
start = t->GivStart();
|
start = t->GetStart();
|
||||||
end = t->GivEnd();
|
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
|
CBotProgram* prog = m_prog; // current program
|
||||||
FunctionName = NULL;
|
FunctionName = NULL;
|
||||||
|
@ -846,8 +846,8 @@ CBotVar* CBotStack::GivStackVars(const char* &FunctionName, int level)
|
||||||
|
|
||||||
if ( pp == NULL || pp->m_instr == NULL ) return NULL;
|
if ( pp == NULL || pp->m_instr == NULL ) return NULL;
|
||||||
|
|
||||||
CBotToken* t = pp->m_instr->GivToken();
|
CBotToken* t = pp->m_instr->GetToken();
|
||||||
FunctionName = t->GivString();
|
FunctionName = t->GetString();
|
||||||
|
|
||||||
return p->m_listVar;
|
return p->m_listVar;
|
||||||
}
|
}
|
||||||
|
@ -924,9 +924,9 @@ bool CBotVar::Save0State(FILE* pf)
|
||||||
{
|
{
|
||||||
if (!WriteWord(pf, 100+m_mPrivate))return false; // private variable?
|
if (!WriteWord(pf, 100+m_mPrivate))return false; // private variable?
|
||||||
if (!WriteWord(pf, m_bStatic))return false; // static 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?
|
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)
|
bool CBotVarInt::Save0State(FILE* pf)
|
||||||
|
@ -1160,7 +1160,7 @@ CBotCStack* CBotCStack::TokenStack(CBotToken* pToken, bool bBlock)
|
||||||
m_next = p; // channel element
|
m_next = p; // channel element
|
||||||
p->m_bBlock = bBlock;
|
p->m_bBlock = bBlock;
|
||||||
|
|
||||||
if (pToken != NULL) p->SetStartError(pToken->GivStart());
|
if (pToken != NULL) p->SetStartError(pToken->GetStart());
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -1200,42 +1200,42 @@ CBotFunction* CBotCStack::ReturnFunc(CBotFunction* inst, CBotCStack* pfils)
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CBotCStack::GivError(int& start, int& end)
|
int CBotCStack::GetError(int& start, int& end)
|
||||||
{
|
{
|
||||||
start = m_start;
|
start = m_start;
|
||||||
end = m_end;
|
end = m_end;
|
||||||
return m_error;
|
return m_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CBotCStack::GivError()
|
int CBotCStack::GetError()
|
||||||
{
|
{
|
||||||
return m_error;
|
return m_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// type of instruction on the stack
|
// type of instruction on the stack
|
||||||
CBotTypResult CBotCStack::GivTypResult(int mode)
|
CBotTypResult CBotCStack::GetTypResult(int mode)
|
||||||
{
|
{
|
||||||
if (m_var == NULL)
|
if (m_var == NULL)
|
||||||
return CBotTypResult(99);
|
return CBotTypResult(99);
|
||||||
return m_var->GivTypResult(mode);
|
return m_var->GetTypResult(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// type of instruction on the stack
|
// type of instruction on the stack
|
||||||
int CBotCStack::GivType(int mode)
|
int CBotCStack::GetType(int mode)
|
||||||
{
|
{
|
||||||
if (m_var == NULL)
|
if (m_var == NULL)
|
||||||
return 99;
|
return 99;
|
||||||
return m_var->GivType(mode);
|
return m_var->GetType(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// pointer on the stack is in what class?
|
// pointer on the stack is in what class?
|
||||||
CBotClass* CBotCStack::GivClass()
|
CBotClass* CBotCStack::GetClass()
|
||||||
{
|
{
|
||||||
if ( m_var == NULL )
|
if ( m_var == NULL )
|
||||||
return 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
|
// type of instruction on the stack
|
||||||
|
@ -1252,14 +1252,14 @@ void CBotCStack::SetType(CBotTypResult& type)
|
||||||
CBotVar* CBotCStack::FindVar(CBotToken* &pToken)
|
CBotVar* CBotCStack::FindVar(CBotToken* &pToken)
|
||||||
{
|
{
|
||||||
CBotCStack* p = this;
|
CBotCStack* p = this;
|
||||||
CBotString name = pToken->GivString();
|
CBotString name = pToken->GetString();
|
||||||
|
|
||||||
while (p != NULL)
|
while (p != NULL)
|
||||||
{
|
{
|
||||||
CBotVar* pp = p->m_listVar;
|
CBotVar* pp = p->m_listVar;
|
||||||
while ( pp != NULL)
|
while ( pp != NULL)
|
||||||
{
|
{
|
||||||
if (name == pp->GivName())
|
if (name == pp->GetName())
|
||||||
{
|
{
|
||||||
return pp;
|
return pp;
|
||||||
}
|
}
|
||||||
|
@ -1282,7 +1282,7 @@ CBotVar* CBotCStack::CopyVar(CBotToken& Token)
|
||||||
|
|
||||||
if ( pVar == NULL) return NULL;
|
if ( pVar == NULL) return NULL;
|
||||||
|
|
||||||
CBotVar* pCopy = CBotVar::Create( "", pVar->GivType() );
|
CBotVar* pCopy = CBotVar::Create( "", pVar->GetType() );
|
||||||
pCopy->Copy(pVar);
|
pCopy->Copy(pVar);
|
||||||
return pCopy;
|
return pCopy;
|
||||||
}
|
}
|
||||||
|
@ -1310,8 +1310,8 @@ void CBotCStack::SetError(int n, CBotToken* p)
|
||||||
{
|
{
|
||||||
if (m_error) return; // does not change existing error
|
if (m_error) return; // does not change existing error
|
||||||
m_error = n;
|
m_error = n;
|
||||||
m_start = p->GivStart();
|
m_start = p->GetStart();
|
||||||
m_end = p->GivEnd();
|
m_end = p->GetEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBotCStack::ResetError(int n, int start, int end)
|
void CBotCStack::ResetError(int n, int start, int end)
|
||||||
|
@ -1325,10 +1325,10 @@ bool CBotCStack::NextToken(CBotToken* &p)
|
||||||
{
|
{
|
||||||
CBotToken* pp = p;
|
CBotToken* pp = p;
|
||||||
|
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
if (p!=NULL) return true;
|
if (p!=NULL) return true;
|
||||||
|
|
||||||
SetError(TX_ENDOF, pp->GivEnd());
|
SetError(TX_ENDOF, pp->GetEnd());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1337,7 +1337,7 @@ void CBotCStack::SetBotCall(CBotProgram* p)
|
||||||
m_prog = p;
|
m_prog = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotProgram* CBotCStack::GivBotCall()
|
CBotProgram* CBotCStack::GetBotCall()
|
||||||
{
|
{
|
||||||
return m_prog;
|
return m_prog;
|
||||||
}
|
}
|
||||||
|
@ -1347,7 +1347,7 @@ void CBotCStack::SetRetType(CBotTypResult& type)
|
||||||
m_retTyp = type;
|
m_retTyp = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotTypResult CBotCStack::GivRetType()
|
CBotTypResult CBotCStack::GetRetType()
|
||||||
{
|
{
|
||||||
return m_retTyp;
|
return m_retTyp;
|
||||||
}
|
}
|
||||||
|
@ -1364,11 +1364,11 @@ void CBotCStack::SetCopyVar( CBotVar* var )
|
||||||
if (m_var) delete m_var; // replacement of a variable
|
if (m_var) delete m_var; // replacement of a variable
|
||||||
|
|
||||||
if ( var == NULL ) return;
|
if ( var == NULL ) return;
|
||||||
m_var = CBotVar::Create("", var->GivTypResult(2));
|
m_var = CBotVar::Create("", var->GetTypResult(2));
|
||||||
m_var->Copy( var );
|
m_var->Copy( var );
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotVar* CBotCStack::GivVar()
|
CBotVar* CBotCStack::GetVar()
|
||||||
{
|
{
|
||||||
return m_var;
|
return m_var;
|
||||||
}
|
}
|
||||||
|
@ -1388,7 +1388,7 @@ void CBotCStack::AddVar(CBotVar* pVar)
|
||||||
*pp = pVar; // added after
|
*pp = pVar; // added after
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if ( pVar->GivUniqNum() == 0 ) ASM_TRAP();
|
if ( pVar->GetUniqNum() == 0 ) ASM_TRAP();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1397,14 +1397,14 @@ void CBotCStack::AddVar(CBotVar* pVar)
|
||||||
bool CBotCStack::CheckVarLocal(CBotToken* &pToken)
|
bool CBotCStack::CheckVarLocal(CBotToken* &pToken)
|
||||||
{
|
{
|
||||||
CBotCStack* p = this;
|
CBotCStack* p = this;
|
||||||
CBotString name = pToken->GivString();
|
CBotString name = pToken->GetString();
|
||||||
|
|
||||||
while (p != NULL)
|
while (p != NULL)
|
||||||
{
|
{
|
||||||
CBotVar* pp = p->m_listVar;
|
CBotVar* pp = p->m_listVar;
|
||||||
while ( pp != NULL)
|
while ( pp != NULL)
|
||||||
{
|
{
|
||||||
if (name == pp->GivName())
|
if (name == pp->GetName())
|
||||||
return true;
|
return true;
|
||||||
pp = pp->m_next;
|
pp = pp->m_next;
|
||||||
}
|
}
|
||||||
|
@ -1420,14 +1420,14 @@ CBotTypResult CBotCStack::CompileCall(CBotToken* &p, CBotVar** ppVars, long& nId
|
||||||
CBotTypResult val(-1);
|
CBotTypResult val(-1);
|
||||||
|
|
||||||
val = CBotCall::CompileCall(p, ppVars, this, nIdent);
|
val = CBotCall::CompileCall(p, ppVars, this, nIdent);
|
||||||
if (val.GivType() < 0)
|
if (val.GetType() < 0)
|
||||||
{
|
{
|
||||||
val = m_prog->GivFunctions()->CompileCall(p->GivString(), ppVars, nIdent);
|
val = m_prog->GetFunctions()->CompileCall(p->GetString(), ppVars, nIdent);
|
||||||
if ( val.GivType() < 0 )
|
if ( val.GetType() < 0 )
|
||||||
{
|
{
|
||||||
// pVar = NULL; // the error is not on a particular parameter
|
// pVar = NULL; // the error is not on a particular parameter
|
||||||
SetError( -val.GivType(), p );
|
SetError( -val.GetType(), p );
|
||||||
val.SetType(-val.GivType());
|
val.SetType(-val.GetType());
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1438,14 +1438,14 @@ CBotTypResult CBotCStack::CompileCall(CBotToken* &p, CBotVar** ppVars, long& nId
|
||||||
|
|
||||||
bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
|
bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
|
||||||
{
|
{
|
||||||
CBotString name = pToken->GivString();
|
CBotString name = pToken->GetString();
|
||||||
|
|
||||||
if ( CBotCall::CheckCall(name) ) return true;
|
if ( CBotCall::CheckCall(name) ) return true;
|
||||||
|
|
||||||
CBotFunction* pp = m_prog->GivFunctions();
|
CBotFunction* pp = m_prog->GetFunctions();
|
||||||
while ( pp != NULL )
|
while ( pp != NULL )
|
||||||
{
|
{
|
||||||
if ( pToken->GivString() == pp->GivName() )
|
if ( pToken->GetString() == pp->GetName() )
|
||||||
{
|
{
|
||||||
// are parameters exactly the same?
|
// are parameters exactly the same?
|
||||||
if ( pp->CheckParam( pParam ) )
|
if ( pp->CheckParam( pParam ) )
|
||||||
|
@ -1457,7 +1457,7 @@ bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
|
||||||
pp = CBotFunction::m_listPublic;
|
pp = CBotFunction::m_listPublic;
|
||||||
while ( pp != NULL )
|
while ( pp != NULL )
|
||||||
{
|
{
|
||||||
if ( pToken->GivString() == pp->GivName() )
|
if ( pToken->GetString() == pp->GetName() )
|
||||||
{
|
{
|
||||||
// are parameters exactly the same?
|
// are parameters exactly the same?
|
||||||
if ( pp->CheckParam( pParam ) )
|
if ( pp->CheckParam( pParam ) )
|
||||||
|
|
|
@ -138,7 +138,7 @@ CBotString::CBotString(const char* p)
|
||||||
m_ptr = NULL;
|
m_ptr = NULL;
|
||||||
if (m_lg>0)
|
if (m_lg>0)
|
||||||
{
|
{
|
||||||
m_ptr = (char*)malloc(m_lg+1);
|
m_ptr = static_cast<char*>(malloc(m_lg+1));
|
||||||
strcpy(m_ptr, p);
|
strcpy(m_ptr, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ CBotString::CBotString(const CBotString& srcString)
|
||||||
m_ptr = NULL;
|
m_ptr = NULL;
|
||||||
if (m_lg>0)
|
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);
|
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;
|
if (m_ptr == NULL) return 0;
|
||||||
return strlen( m_ptr );
|
return strlen( m_ptr );
|
||||||
|
@ -285,7 +285,7 @@ CBotString CBotString::Mid(int start, int lg)
|
||||||
|
|
||||||
if ( lg < 0 ) lg = m_lg - start;
|
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);
|
strcpy(p, m_ptr+start);
|
||||||
p[lg] = 0;
|
p[lg] = 0;
|
||||||
|
|
||||||
|
@ -322,7 +322,7 @@ bool CBotString::LoadString(unsigned int id)
|
||||||
m_ptr = NULL;
|
m_ptr = NULL;
|
||||||
if (m_lg > 0)
|
if (m_lg > 0)
|
||||||
{
|
{
|
||||||
m_ptr = (char*)malloc(m_lg+1);
|
m_ptr = static_cast<char*>(malloc(m_lg+1));
|
||||||
strcpy(m_ptr, str);
|
strcpy(m_ptr, str);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -339,7 +339,7 @@ const CBotString& CBotString::operator=(const CBotString& stringSrc)
|
||||||
|
|
||||||
if (m_lg > 0)
|
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);
|
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)
|
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);
|
strcpy(p, m_ptr);
|
||||||
char* pp = p + m_lg;
|
char* pp = p + m_lg;
|
||||||
|
@ -392,7 +392,7 @@ const CBotString& CBotString::operator=(const char* pString)
|
||||||
|
|
||||||
if (m_lg != 0)
|
if (m_lg != 0)
|
||||||
{
|
{
|
||||||
m_ptr = (char*)malloc(m_lg+1);
|
m_ptr = static_cast<char*>(malloc(m_lg+1));
|
||||||
strcpy(m_ptr, pString);
|
strcpy(m_ptr, pString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -549,7 +549,7 @@ CBotStringArray::~CBotStringArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int CBotStringArray::GivSize()
|
int CBotStringArray::GetSize()
|
||||||
{
|
{
|
||||||
return m_nSize;
|
return m_nSize;
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,25 +123,25 @@ const CBotToken& CBotToken::operator=(const CBotToken& src)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int CBotToken::GivType()
|
int CBotToken::GetType()
|
||||||
{
|
{
|
||||||
if (this == NULL) return 0;
|
if (this == NULL) return 0;
|
||||||
if (m_type == TokenTypKeyWord) return m_IdKeyWord;
|
if (m_type == TokenTypKeyWord) return m_IdKeyWord;
|
||||||
return m_type;
|
return m_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
long CBotToken::GivIdKey()
|
long CBotToken::GetIdKey()
|
||||||
{
|
{
|
||||||
return m_IdKeyWord;
|
return m_IdKeyWord;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotToken* CBotToken::GivNext()
|
CBotToken* CBotToken::GetNext()
|
||||||
{
|
{
|
||||||
if (this == NULL) return NULL;
|
if (this == NULL) return NULL;
|
||||||
return m_next;
|
return m_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotToken* CBotToken::GivPrev()
|
CBotToken* CBotToken::GetPrev()
|
||||||
{
|
{
|
||||||
if (this == NULL) return NULL;
|
if (this == NULL) return NULL;
|
||||||
return m_prev;
|
return m_prev;
|
||||||
|
@ -159,12 +159,12 @@ void CBotToken::AddNext(CBotToken* p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CBotString& CBotToken::GivString()
|
CBotString& CBotToken::GetString()
|
||||||
{
|
{
|
||||||
return m_Text;
|
return m_Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotString& CBotToken::GivSep()
|
CBotString& CBotToken::GetSep()
|
||||||
{
|
{
|
||||||
return m_Sep;
|
return m_Sep;
|
||||||
}
|
}
|
||||||
|
@ -175,13 +175,13 @@ void CBotToken::SetString(const char* name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int CBotToken::GivStart()
|
int CBotToken::GetStart()
|
||||||
{
|
{
|
||||||
if (this == NULL) return -1;
|
if (this == NULL) return -1;
|
||||||
return m_start;
|
return m_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CBotToken::GivEnd()
|
int CBotToken::GetEnd()
|
||||||
{
|
{
|
||||||
if (this == NULL) return -1;
|
if (this == NULL) return -1;
|
||||||
return m_end;
|
return m_end;
|
||||||
|
@ -309,7 +309,7 @@ cc: mot += c;
|
||||||
if (CharInList(mot[0], sep3)) // an operational separator?
|
if (CharInList(mot[0], sep3)) // an operational separator?
|
||||||
{
|
{
|
||||||
CBotString motc = mot;
|
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
|
mot += c; // build the word
|
||||||
c = *(program++); // next character
|
c = *(program++); // next character
|
||||||
|
@ -367,9 +367,9 @@ bis:
|
||||||
if (mot[0] == '\"') token->m_type = TokenTypString;
|
if (mot[0] == '\"') token->m_type = TokenTypString;
|
||||||
if (first) token->m_type = 0;
|
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;
|
if (token->m_IdKeyWord > 0) token->m_type = TokenTypKeyWord;
|
||||||
else GivKeyDefNum(mot, token) ; // treats DefineNum
|
else GetKeyDefNum(mot, token) ; // treats DefineNum
|
||||||
|
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
@ -391,9 +391,9 @@ CBotToken* CBotToken::CompileTokens(const char* program, int& error)
|
||||||
if (tokenbase == NULL) return NULL;
|
if (tokenbase == NULL) return NULL;
|
||||||
|
|
||||||
tokenbase->m_start = pos;
|
tokenbase->m_start = pos;
|
||||||
pos += tokenbase->m_Text.GivLength();
|
pos += tokenbase->m_Text.GetLength();
|
||||||
tokenbase->m_end = pos;
|
tokenbase->m_end = pos;
|
||||||
pos += tokenbase->m_Sep.GivLength();
|
pos += tokenbase->m_Sep.GetLength();
|
||||||
|
|
||||||
char* pp = p;
|
char* pp = p;
|
||||||
while (NULL != (nxt = NextToken(p, error)))
|
while (NULL != (nxt = NextToken(p, error)))
|
||||||
|
@ -403,11 +403,11 @@ CBotToken* CBotToken::CompileTokens(const char* program, int& error)
|
||||||
prv = nxt; // advance
|
prv = nxt; // advance
|
||||||
|
|
||||||
nxt->m_start = pos;
|
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;
|
nxt->m_end = pos;
|
||||||
pos += nxt->m_Sep.GivLength();*/
|
pos += nxt->m_Sep.GetLength();*/
|
||||||
pos += (p - pp); // total size
|
pos += (p - pp); // total size
|
||||||
nxt->m_end = pos - nxt->m_Sep.GivLength();
|
nxt->m_end = pos - nxt->m_Sep.GetLength();
|
||||||
pp = p;
|
pp = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,15 +429,15 @@ void CBotToken::Delete(CBotToken* pToken)
|
||||||
|
|
||||||
// search if a word is part of the keywords
|
// search if a word is part of the keywords
|
||||||
|
|
||||||
int CBotToken::GivKeyWords(const char* w)
|
int CBotToken::GetKeyWords(const char* w)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int l = m_ListKeyWords.GivSize();
|
int l = m_ListKeyWords.GetSize();
|
||||||
|
|
||||||
if (l == 0)
|
if (l == 0)
|
||||||
{
|
{
|
||||||
LoadKeyWords(); // takes the list for the first time
|
LoadKeyWords(); // takes the list for the first time
|
||||||
l = m_ListKeyWords.GivSize();
|
l = m_ListKeyWords.GetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < l; i++)
|
for (i = 0; i < l; i++)
|
||||||
|
@ -448,10 +448,10 @@ int CBotToken::GivKeyWords(const char* w)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBotToken::GivKeyDefNum(const char* w, CBotToken* &token)
|
bool CBotToken::GetKeyDefNum(const char* w, CBotToken* &token)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int l = m_ListKeyDefine.GivSize();
|
int l = m_ListKeyDefine.GetSize();
|
||||||
|
|
||||||
for (i = 0; i < l; i++)
|
for (i = 0; i < l; i++)
|
||||||
{
|
{
|
||||||
|
@ -510,7 +510,7 @@ void CBotToken::LoadKeyWords()
|
||||||
bool CBotToken::DefineNum(const char* name, long val)
|
bool CBotToken::DefineNum(const char* name, long val)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int l = m_ListKeyDefine.GivSize();
|
int l = m_ListKeyDefine.GetSize();
|
||||||
|
|
||||||
for (i = 0; i < l; i++)
|
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)
|
bool IsOfType(CBotToken* &p, int type1, int type2)
|
||||||
{
|
{
|
||||||
if (p->GivType() == type1 ||
|
if (p->GetType() == type1 ||
|
||||||
p->GivType() == type2 )
|
p->GetType() == type2 )
|
||||||
{
|
{
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -539,7 +539,7 @@ bool IsOfTypeList(CBotToken* &p, int type1, ...)
|
||||||
{
|
{
|
||||||
int i = type1;
|
int i = type1;
|
||||||
int max = 20;
|
int max = 20;
|
||||||
int type = p->GivType();
|
int type = p->GetType();
|
||||||
|
|
||||||
va_list marker;
|
va_list marker;
|
||||||
va_start( marker, type1 ); /* Initialize variable arguments. */
|
va_start( marker, type1 ); /* Initialize variable arguments. */
|
||||||
|
@ -548,7 +548,7 @@ bool IsOfTypeList(CBotToken* &p, int type1, ...)
|
||||||
{
|
{
|
||||||
if (type == i)
|
if (type == i)
|
||||||
{
|
{
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
va_end( marker ); /* Reset variable arguments. */
|
va_end( marker ); /* Reset variable arguments. */
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,11 +136,11 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera
|
||||||
if (left == NULL) return pStack->Return(NULL, pStk); // if error, transmit
|
if (left == NULL) return pStack->Return(NULL, pStk); // if error, transmit
|
||||||
|
|
||||||
// did we expected the operand?
|
// did we expected the operand?
|
||||||
int TypeOp = p->GivType();
|
int TypeOp = p->GetType();
|
||||||
if ( IsInList( TypeOp, pOperations, typemasque ) )
|
if ( IsInList( TypeOp, pOperations, typemasque ) )
|
||||||
{
|
{
|
||||||
CBotTypResult type1, type2;
|
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;
|
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();
|
CBotLogicExpr* inst = new CBotLogicExpr();
|
||||||
inst->m_condition = left;
|
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);
|
inst->m_op1 = CBotExpression::Compile(p, pStk);
|
||||||
CBotToken* pp = p;
|
CBotToken* pp = p;
|
||||||
if ( inst->m_op1 == NULL || !IsOfType( p, ID_DOTS ) )
|
if ( inst->m_op1 == NULL || !IsOfType( p, ID_DOTS ) )
|
||||||
{
|
{
|
||||||
pStk->SetError( TX_MISDOTS, p->GivStart());
|
pStk->SetError( TX_MISDOTS, p->GetStart());
|
||||||
delete inst;
|
delete inst;
|
||||||
return pStack->Return(NULL, pStk);
|
return pStack->Return(NULL, pStk);
|
||||||
}
|
}
|
||||||
type1 = pStk->GivTypResult();
|
type1 = pStk->GetTypResult();
|
||||||
|
|
||||||
inst->m_op2 = CBotExpression::Compile(p, pStk);
|
inst->m_op2 = CBotExpression::Compile(p, pStk);
|
||||||
if ( inst->m_op2 == NULL )
|
if ( inst->m_op2 == NULL )
|
||||||
{
|
{
|
||||||
pStk->SetError( TX_ENDOF, p->GivStart() );
|
pStk->SetError( TX_ENDOF, p->GetStart() );
|
||||||
delete inst;
|
delete inst;
|
||||||
return pStack->Return(NULL, pStk);
|
return pStack->Return(NULL, pStk);
|
||||||
}
|
}
|
||||||
type2 = pStk->GivTypResult();
|
type2 = pStk->GetTypResult();
|
||||||
if (!TypeCompatible(type1, type2))
|
if (!TypeCompatible(type1, type2))
|
||||||
{
|
{
|
||||||
pStk->SetError( TX_BAD2TYPE, pp );
|
pStk->SetError( TX_BAD2TYPE, pp );
|
||||||
|
@ -187,7 +187,7 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera
|
||||||
inst->SetToken(p); // stores the operation
|
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
|
// 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
|
// there is an second operand acceptable
|
||||||
|
|
||||||
type2 = pStk->GivTypResult(); // what kind of results?
|
type2 = pStk->GetTypResult(); // what kind of results?
|
||||||
|
|
||||||
// what kind of result?
|
// 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) )
|
if ( TypeOp == ID_ADD && type1.Eq(CBotTypString) )
|
||||||
{
|
{
|
||||||
TypeRes = CBotTypString;
|
TypeRes = CBotTypString;
|
||||||
|
@ -232,17 +232,17 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera
|
||||||
inst->m_leftop = left;
|
inst->m_leftop = left;
|
||||||
|
|
||||||
// special for evaluation of the operations of the same level from left to right
|
// 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
|
CBotTwoOpExpr* i = new CBotTwoOpExpr(); // element for operation
|
||||||
i->SetToken(p); // stores the operation
|
i->SetToken(p); // stores the operation
|
||||||
i->m_leftop = inst; // left operand
|
i->m_leftop = inst; // left operand
|
||||||
type1 = TypeRes;
|
type1 = TypeRes;
|
||||||
|
|
||||||
p = p->GivNext(); // advance after
|
p = p->GetNext(); // advance after
|
||||||
i->m_rightop = CBotTwoOpExpr::Compile( p, pStk, pOp );
|
i->m_rightop = CBotTwoOpExpr::Compile( p, pStk, pOp );
|
||||||
type2 = pStk->GivTypResult();
|
type2 = pStk->GetTypResult();
|
||||||
|
|
||||||
if ( !TypeCompatible (type1, type2, TypeOp) ) // the results are compatible
|
if ( !TypeCompatible (type1, type2, TypeOp) ) // the results are compatible
|
||||||
{
|
{
|
||||||
|
@ -252,7 +252,7 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( TypeRes != CBotTypString )
|
if ( TypeRes != CBotTypString )
|
||||||
TypeRes = MAX(type1.GivType(), type2.GivType());
|
TypeRes = MAX(type1.GetType(), type2.GetType());
|
||||||
inst = i;
|
inst = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera
|
||||||
|
|
||||||
bool IsNan(CBotVar* left, CBotVar* right, int* err = NULL)
|
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 ;
|
if ( err != NULL ) *err = TX_OPNAN ;
|
||||||
return true;
|
return true;
|
||||||
|
@ -302,19 +302,19 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
|
||||||
|
|
||||||
// according to recovery, it may be in one of two states
|
// 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?
|
if (!m_leftop->Execute(pStk1) ) return false; // interrupted here?
|
||||||
|
|
||||||
// for OR and AND logic does not evaluate the second expression if not necessary
|
// for OR and AND logic does not evaluate the second expression if not necessary
|
||||||
if ( (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( (CBotToken*)NULL, CBotTypBoolean);
|
||||||
res->SetValInt(false);
|
res->SetValInt(false);
|
||||||
pStk1->SetVar(res);
|
pStk1->SetVar(res);
|
||||||
return pStack->Return(pStk1); // transmits the result
|
return pStack->Return(pStk1); // transmits the result
|
||||||
}
|
}
|
||||||
if ( (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( (CBotToken*)NULL, CBotTypBoolean);
|
||||||
res->SetValInt(true);
|
res->SetValInt(true);
|
||||||
|
@ -334,28 +334,28 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
|
||||||
// or return in case of recovery
|
// or return in case of recovery
|
||||||
|
|
||||||
// 2e état, évalue l'opérande de droite
|
// 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?
|
if ( !m_rightop->Execute(pStk2) ) return false; // interrupted here?
|
||||||
pStk2->IncState();
|
pStk2->IncState();
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotTypResult type1 = pStk1->GivTypResult(); // what kind of results?
|
CBotTypResult type1 = pStk1->GetTypResult(); // what kind of results?
|
||||||
CBotTypResult type2 = pStk2->GivTypResult();
|
CBotTypResult type2 = pStk2->GetTypResult();
|
||||||
|
|
||||||
CBotStack* pStk3 = pStk2->AddStack(this); // adds an item to the stack
|
CBotStack* pStk3 = pStk2->AddStack(this); // adds an item to the stack
|
||||||
if ( pStk3->IfStep() ) return false; // shows the operation if step by step
|
if ( pStk3->IfStep() ) return false; // shows the operation if step by step
|
||||||
|
|
||||||
// creates a temporary variable to put the result
|
// creates a temporary variable to put the result
|
||||||
// what kind of 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;
|
TypeRes = CBotTypString;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( GivTokenType() )
|
switch ( GetTokenType() )
|
||||||
{
|
{
|
||||||
case ID_LOG_OR:
|
case ID_LOG_OR:
|
||||||
case ID_LOG_AND:
|
case ID_LOG_AND:
|
||||||
|
@ -377,9 +377,9 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
|
||||||
CBotVar* result = CBotVar::Create( (CBotToken*)NULL, TypeRes);
|
CBotVar* result = CBotVar::Create( (CBotToken*)NULL, TypeRes);
|
||||||
|
|
||||||
// creates a variable to perform the calculation in the appropriate type
|
// creates a variable to perform the calculation in the appropriate type
|
||||||
TypeRes = MAX(type1.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;
|
TypeRes = CBotTypString;
|
||||||
}
|
}
|
||||||
|
@ -387,15 +387,15 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
|
||||||
CBotVar* temp;
|
CBotVar* temp;
|
||||||
|
|
||||||
if ( TypeRes == CBotTypPointer ) TypeRes = CBotTypNullPointer;
|
if ( TypeRes == CBotTypPointer ) TypeRes = CBotTypNullPointer;
|
||||||
if ( TypeRes == CBotTypClass ) temp = CBotVar::Create( (CBotToken*)NULL, CBotTypResult(CBotTypIntrinsic, type1.GivClass() ) );
|
if ( TypeRes == CBotTypClass ) temp = CBotVar::Create( (CBotToken*)NULL, CBotTypResult(CBotTypIntrinsic, type1.GetClass() ) );
|
||||||
else temp = CBotVar::Create( (CBotToken*)NULL, TypeRes );
|
else temp = CBotVar::Create( (CBotToken*)NULL, TypeRes );
|
||||||
|
|
||||||
int err = 0;
|
int err = 0;
|
||||||
// is a operation according to request
|
// is a operation according to request
|
||||||
CBotVar* left = pStk1->GivVar();
|
CBotVar* left = pStk1->GetVar();
|
||||||
CBotVar* right = pStk2->GivVar();
|
CBotVar* right = pStk2->GetVar();
|
||||||
|
|
||||||
switch (GivTokenType())
|
switch (GetTokenType())
|
||||||
{
|
{
|
||||||
case ID_ADD:
|
case ID_ADD:
|
||||||
if ( !IsNan(left, right, &err) ) result->Add(left , right); // addition
|
if ( !IsNan(left, right, &err) ) result->Add(left , right); // addition
|
||||||
|
@ -433,13 +433,13 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
|
||||||
break;
|
break;
|
||||||
case ID_EQ:
|
case ID_EQ:
|
||||||
if ( IsNan(left, right) )
|
if ( IsNan(left, right) )
|
||||||
result->SetValInt(left->GivInit() == right->GivInit()) ;
|
result->SetValInt(left->GetInit() == right->GetInit()) ;
|
||||||
else
|
else
|
||||||
result->SetValInt(temp->Eq(left , right)); // equal
|
result->SetValInt(temp->Eq(left , right)); // equal
|
||||||
break;
|
break;
|
||||||
case ID_NE:
|
case ID_NE:
|
||||||
if ( IsNan(left, right) )
|
if ( IsNan(left, right) )
|
||||||
result->SetValInt(left ->GivInit() != right->GivInit()) ;
|
result->SetValInt(left ->GetInit() != right->GetInit()) ;
|
||||||
else
|
else
|
||||||
result->SetValInt(temp->Ne(left , right)); // different
|
result->SetValInt(temp->Ne(left , right)); // different
|
||||||
break;
|
break;
|
||||||
|
@ -485,7 +485,7 @@ void CBotTwoOpExpr::RestoreState(CBotStack* &pStack, bool bMain)
|
||||||
|
|
||||||
// according to recovery, it may be in one of two states
|
// 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!
|
m_leftop->RestoreState(pStk1, bMain); // interrupted here!
|
||||||
return;
|
return;
|
||||||
|
@ -495,7 +495,7 @@ void CBotTwoOpExpr::RestoreState(CBotStack* &pStack, bool bMain)
|
||||||
if ( pStk2 == NULL ) return;
|
if ( pStk2 == NULL ) return;
|
||||||
|
|
||||||
// second state, evaluates the right operand
|
// second state, evaluates the right operand
|
||||||
if ( pStk2->GivState() == 0 )
|
if ( pStk2->GetState() == 0 )
|
||||||
{
|
{
|
||||||
m_rightop->RestoreState(pStk2, bMain); // interrupted here!
|
m_rightop->RestoreState(pStk2, bMain); // interrupted here!
|
||||||
return;
|
return;
|
||||||
|
@ -509,13 +509,13 @@ bool CBotLogicExpr::Execute(CBotStack* &pStack)
|
||||||
// or return in case of recovery
|
// or return in case of recovery
|
||||||
// if ( pStk1 == EOX ) return true;
|
// if ( pStk1 == EOX ) return true;
|
||||||
|
|
||||||
if ( pStk1->GivState() == 0 )
|
if ( pStk1->GetState() == 0 )
|
||||||
{
|
{
|
||||||
if ( !m_condition->Execute(pStk1) ) return false;
|
if ( !m_condition->Execute(pStk1) ) return false;
|
||||||
if (!pStk1->SetState(1)) return false;
|
if (!pStk1->SetState(1)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pStk1->GivVal() == true )
|
if ( pStk1->GetVal() == true )
|
||||||
{
|
{
|
||||||
if ( !m_op1->Execute(pStk1) ) return false;
|
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
|
CBotStack* pStk1 = pStack->RestoreStack(this); // adds an item to the stack
|
||||||
if ( pStk1 == NULL ) return;
|
if ( pStk1 == NULL ) return;
|
||||||
|
|
||||||
if ( pStk1->GivState() == 0 )
|
if ( pStk1->GetState() == 0 )
|
||||||
{
|
{
|
||||||
m_condition->RestoreState(pStk1, bMain);
|
m_condition->RestoreState(pStk1, bMain);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pStk1->GivVal() == true )
|
if ( pStk1->GetVal() == true )
|
||||||
{
|
{
|
||||||
m_op1->RestoreState(pStk1, bMain);
|
m_op1->RestoreState(pStk1, bMain);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -55,7 +55,7 @@ CBotInstr* CBotWhile::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
if ( IsOfType( p, TokenTypVar ) &&
|
if ( IsOfType( p, TokenTypVar ) &&
|
||||||
IsOfType( p, ID_DOTS ) )
|
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);
|
inst->SetToken(p);
|
||||||
|
@ -95,7 +95,7 @@ bool CBotWhile :: Execute(CBotStack* &pj)
|
||||||
|
|
||||||
if ( pile->IfStep() ) return false;
|
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)
|
{ // there are two possible states (depending on recovery)
|
||||||
case 0:
|
case 0:
|
||||||
// evaluates the condition
|
// evaluates the condition
|
||||||
|
@ -104,7 +104,7 @@ bool CBotWhile :: Execute(CBotStack* &pj)
|
||||||
// the result of the condition is on the stack
|
// the result of the condition is on the stack
|
||||||
|
|
||||||
// terminates if an error or if the condition is false
|
// 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
|
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
|
CBotStack* pile = pj->RestoreStack(this); // adds an item to the stack
|
||||||
if ( pile == NULL ) return;
|
if ( pile == NULL ) return;
|
||||||
|
|
||||||
switch( pile->GivState() )
|
switch( pile->GetState() )
|
||||||
{ // there are two possible states (depending on recovery)
|
{ // there are two possible states (depending on recovery)
|
||||||
case 0:
|
case 0:
|
||||||
// evaluates the condition
|
// evaluates the condition
|
||||||
|
@ -181,7 +181,7 @@ CBotInstr* CBotRepeat::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
if ( IsOfType( p, TokenTypVar ) &&
|
if ( IsOfType( p, TokenTypVar ) &&
|
||||||
IsOfType( p, ID_DOTS ) )
|
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);
|
inst->SetToken(p);
|
||||||
|
@ -194,7 +194,7 @@ CBotInstr* CBotRepeat::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
CBotToken* ppp = p; // preserves the ^ token (starting position)
|
CBotToken* ppp = p; // preserves the ^ token (starting position)
|
||||||
if ( NULL != (inst->m_NbIter = CBotExpression::Compile( p, pStk )) )
|
if ( NULL != (inst->m_NbIter = CBotExpression::Compile( p, pStk )) )
|
||||||
{
|
{
|
||||||
if ( pStk->GivType() < CBotTypLong )
|
if ( pStk->GetType() < CBotTypLong )
|
||||||
{
|
{
|
||||||
if ( IsOfType(p, ID_CLOSEPAR ) )
|
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
|
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->SetStartError(ppp->GetStart());
|
||||||
pStk->SetError( TX_BADTYPE, p->GivStart() );
|
pStk->SetError( TX_BADTYPE, p->GetStart() );
|
||||||
}
|
}
|
||||||
pStack->SetError(TX_ENDOF, p);
|
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
|
delete inst; // error, frees up
|
||||||
return pStack->Return(NULL, pStk); // no object, the error is on the stack
|
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;
|
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)
|
{ // there are two possible states (depending on recovery)
|
||||||
case 0:
|
case 0:
|
||||||
// evaluates the number of iterations
|
// evaluates the number of iterations
|
||||||
|
@ -243,7 +243,7 @@ bool CBotRepeat :: Execute(CBotStack* &pj)
|
||||||
|
|
||||||
// terminates if an error or if the condition is false
|
// terminates if an error or if the condition is false
|
||||||
int n;
|
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
|
return pj->Return(pile); // sends the results and releases the stack
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ bool CBotRepeat :: Execute(CBotStack* &pj)
|
||||||
if ( m_Block != NULL &&
|
if ( m_Block != NULL &&
|
||||||
!m_Block->Execute(pile) )
|
!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
|
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
|
// returns to the test again
|
||||||
if (!pile->SetState(pile->GivState()-1, 0)) return false;
|
if (!pile->SetState(pile->GetState()-1, 0)) return false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ void CBotRepeat :: RestoreState(CBotStack* &pj, bool bMain)
|
||||||
CBotStack* pile = pj->RestoreStack(this); // adds an item to the stack
|
CBotStack* pile = pj->RestoreStack(this); // adds an item to the stack
|
||||||
if ( pile == NULL ) return;
|
if ( pile == NULL ) return;
|
||||||
|
|
||||||
switch( pile->GivState() )
|
switch( pile->GetState() )
|
||||||
{ // there are two possible states (depending on recovery)
|
{ // there are two possible states (depending on recovery)
|
||||||
case 0:
|
case 0:
|
||||||
// evaluates the condition
|
// evaluates the condition
|
||||||
|
@ -325,7 +325,7 @@ CBotInstr* CBotDo::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
if ( IsOfType( p, TokenTypVar ) &&
|
if ( IsOfType( p, TokenTypVar ) &&
|
||||||
IsOfType( p, ID_DOTS ) )
|
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);
|
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
|
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
|
delete inst; // error, frees up
|
||||||
|
@ -370,7 +370,7 @@ bool CBotDo :: Execute(CBotStack* &pj)
|
||||||
|
|
||||||
if ( pile->IfStep() ) return false;
|
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)
|
{ // there are two possible states (depending on recovery)
|
||||||
case 0:
|
case 0:
|
||||||
// evaluates the associated statement block
|
// evaluates the associated statement block
|
||||||
|
@ -396,7 +396,7 @@ bool CBotDo :: Execute(CBotStack* &pj)
|
||||||
// the result of the condition is on the stack
|
// the result of the condition is on the stack
|
||||||
|
|
||||||
// terminates if an error or if the condition is false
|
// 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
|
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
|
CBotStack* pile = pj->RestoreStack(this); // adds an item to the stack
|
||||||
if ( pile == NULL ) return;
|
if ( pile == NULL ) return;
|
||||||
|
|
||||||
switch( pile->GivState() )
|
switch( pile->GetState() )
|
||||||
{ // there are two possible states (depending on recovery)
|
{ // there are two possible states (depending on recovery)
|
||||||
case 0:
|
case 0:
|
||||||
// restores the assosiated statement's block
|
// restores the assosiated statement's block
|
||||||
|
@ -459,7 +459,7 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
if ( IsOfType( p, TokenTypVar ) &&
|
if ( IsOfType( p, TokenTypVar ) &&
|
||||||
IsOfType( p, ID_DOTS ) )
|
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);
|
inst->SetToken(p);
|
||||||
|
@ -467,7 +467,7 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
|
||||||
if ( !IsOfType(p, ID_OPENPAR)) // missing parenthesis ?
|
if ( !IsOfType(p, ID_OPENPAR)) // missing parenthesis ?
|
||||||
{
|
{
|
||||||
pStack->SetError(TX_OPENPAR, p->GivStart());
|
pStack->SetError(TX_OPENPAR, p->GetStart());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,7 +479,7 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
{
|
{
|
||||||
if ( !IsOfType(p, ID_SEP)) // lack the semicolon?
|
if ( !IsOfType(p, ID_SEP)) // lack the semicolon?
|
||||||
{
|
{
|
||||||
pStack->SetError(TX_OPENPAR, p->GivStart());
|
pStack->SetError(TX_OPENPAR, p->GetStart());
|
||||||
delete inst;
|
delete inst;
|
||||||
return pStack->Return(NULL, pStk); // no object, the error is on the stack
|
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?
|
if ( !IsOfType(p, ID_SEP)) // lack the semicolon?
|
||||||
{
|
{
|
||||||
pStack->SetError(TX_OPENPAR, p->GivStart());
|
pStack->SetError(TX_OPENPAR, p->GetStart());
|
||||||
delete inst;
|
delete inst;
|
||||||
return pStack->Return(NULL, pStk); // no object, the error is on the stack
|
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() )
|
if ( pStk->IsOk() )
|
||||||
return pStack->Return(inst, pStk);;
|
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;
|
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)
|
{ // there are four possible states (depending on recovery)
|
||||||
case 0:
|
case 0:
|
||||||
// initialize
|
// initialize
|
||||||
|
@ -539,7 +539,7 @@ bool CBotFor :: Execute(CBotStack* &pj)
|
||||||
// the result of the condition is on the stack
|
// the result of the condition is on the stack
|
||||||
|
|
||||||
// terminates if an error or if the condition is false
|
// 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
|
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)
|
CBotStack* pile = pj->RestoreStack(this); // adds an item to the stack (variables locales)
|
||||||
if ( pile == NULL ) return;
|
if ( pile == NULL ) return;
|
||||||
|
|
||||||
switch( pile->GivState() )
|
switch( pile->GetState() )
|
||||||
{ // there are four possible states (depending on recovery)
|
{ // there are four possible states (depending on recovery)
|
||||||
case 0:
|
case 0:
|
||||||
// initialize
|
// initialize
|
||||||
|
@ -669,13 +669,13 @@ bool CBotListExpression::Execute(CBotStack* &pj)
|
||||||
CBotStack* pile = pj->AddStack(); // essential
|
CBotStack* pile = pj->AddStack(); // essential
|
||||||
CBotInstr* p = m_Expr; // the first expression
|
CBotInstr* p = m_Expr; // the first expression
|
||||||
|
|
||||||
int state = pile->GivState();
|
int state = pile->GetState();
|
||||||
while (state-->0) p = p->GivNext(); // returns to the interrupted operation
|
while (state-->0) p = p->GetNext(); // returns to the interrupted operation
|
||||||
|
|
||||||
if ( p != NULL ) while (true)
|
if ( p != NULL ) while (true)
|
||||||
{
|
{
|
||||||
if ( !p->Execute(pile) ) return false;
|
if ( !p->Execute(pile) ) return false;
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
if ( p == NULL ) break;
|
if ( p == NULL ) break;
|
||||||
if (!pile->IncState()) return false; // ready for next
|
if (!pile->IncState()) return false; // ready for next
|
||||||
}
|
}
|
||||||
|
@ -691,7 +691,7 @@ void CBotListExpression::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
{
|
{
|
||||||
pile = pj->RestoreStack();
|
pile = pj->RestoreStack();
|
||||||
if ( pile == NULL ) return;
|
if ( pile == NULL ) return;
|
||||||
state = pile->GivState();
|
state = pile->GetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
CBotInstr* p = m_Expr; // the first expression
|
CBotInstr* p = m_Expr; // the first expression
|
||||||
|
@ -699,7 +699,7 @@ void CBotListExpression::RestoreState(CBotStack* &pj, bool bMain)
|
||||||
while (p != NULL && state-->0)
|
while (p != NULL && state-->0)
|
||||||
{
|
{
|
||||||
p->RestoreState(pile, false);
|
p->RestoreState(pile, false);
|
||||||
p = p->GivNext(); // returns to the interrupted operation
|
p = p->GetNext(); // returns to the interrupted operation
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( p != NULL )
|
if ( p != NULL )
|
||||||
|
@ -741,7 +741,7 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
{
|
{
|
||||||
if ( NULL != (inst->m_Value = CBotExpression::Compile( p, pStk )) )
|
if ( NULL != (inst->m_Value = CBotExpression::Compile( p, pStk )) )
|
||||||
{
|
{
|
||||||
if ( pStk->GivType() < CBotTypLong )
|
if ( pStk->GetType() < CBotTypLong )
|
||||||
{
|
{
|
||||||
if ( IsOfType(p, ID_CLOSEPAR ) )
|
if ( IsOfType(p, ID_CLOSEPAR ) )
|
||||||
{
|
{
|
||||||
|
@ -751,7 +751,7 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
|
||||||
while( !IsOfType( p, ID_CLBLK ) )
|
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
|
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 )
|
if ( inst->m_Block == NULL )
|
||||||
{
|
{
|
||||||
pStk->SetError(TX_NOCASE, p->GivStart());
|
pStk->SetError(TX_NOCASE, p->GetStart());
|
||||||
delete inst;
|
delete inst;
|
||||||
return pStack->Return(NULL, pStk);
|
return pStack->Return(NULL, pStk);
|
||||||
}
|
}
|
||||||
|
@ -793,21 +793,21 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
|
||||||
if ( inst->m_Block == NULL )
|
if ( inst->m_Block == NULL )
|
||||||
{
|
{
|
||||||
pStk->SetError(TX_NOCASE, p->GivStart());
|
pStk->SetError(TX_NOCASE, p->GetStart());
|
||||||
delete inst;
|
delete inst;
|
||||||
return pStack->Return(NULL, pStk);
|
return pStack->Return(NULL, pStk);
|
||||||
}
|
}
|
||||||
// the statement block is ok
|
// the statement block is ok
|
||||||
return pStack->Return(inst, pStk); // return an object to the application
|
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
|
delete inst; // error, frees up
|
||||||
return pStack->Return(NULL, pStk); // no object, the error is on the stack
|
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
|
CBotInstr* p = m_Block; // first expression
|
||||||
|
|
||||||
int state = pile1->GivState();
|
int state = pile1->GetState();
|
||||||
if (state == 0)
|
if (state == 0)
|
||||||
{
|
{
|
||||||
if ( !m_Value->Execute(pile1) ) return false;
|
if ( !m_Value->Execute(pile1) ) return false;
|
||||||
|
@ -834,14 +834,14 @@ bool CBotSwitch :: Execute(CBotStack* &pj)
|
||||||
if ( state == -1 )
|
if ( state == -1 )
|
||||||
{
|
{
|
||||||
state = 0;
|
state = 0;
|
||||||
int val = pile1->GivVal(); // result of the value
|
int val = pile1->GetVal(); // result of the value
|
||||||
|
|
||||||
CBotStack* pile2 = pile1->AddStack();
|
CBotStack* pile2 = pile1->AddStack();
|
||||||
while ( p != NULL ) // search for the corresponding case in a list
|
while ( p != NULL ) // search for the corresponding case in a list
|
||||||
{
|
{
|
||||||
state++;
|
state++;
|
||||||
if ( p->CompCase( pile2, val ) ) break; // found the case
|
if ( p->CompCase( pile2, val ) ) break; // found the case
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
}
|
}
|
||||||
pile2->Delete();
|
pile2->Delete();
|
||||||
|
|
||||||
|
@ -851,13 +851,13 @@ bool CBotSwitch :: Execute(CBotStack* &pj)
|
||||||
}
|
}
|
||||||
|
|
||||||
p = m_Block; // returns to the beginning
|
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 )
|
while( p != NULL )
|
||||||
{
|
{
|
||||||
if ( !p->Execute(pile1) ) return pj->BreakReturn(pile1);
|
if ( !p->Execute(pile1) ) return pj->BreakReturn(pile1);
|
||||||
if ( !pile1->IncState() ) return false;
|
if ( !pile1->IncState() ) return false;
|
||||||
p = p->GivNext();
|
p = p->GetNext();
|
||||||
}
|
}
|
||||||
return pj->Return(pile1);
|
return pj->Return(pile1);
|
||||||
}
|
}
|
||||||
|
@ -871,7 +871,7 @@ void CBotSwitch :: RestoreState(CBotStack* &pj, bool bMain)
|
||||||
|
|
||||||
CBotInstr* p = m_Block; // first expression
|
CBotInstr* p = m_Block; // first expression
|
||||||
|
|
||||||
int state = pile1->GivState();
|
int state = pile1->GetState();
|
||||||
if (state == 0)
|
if (state == 0)
|
||||||
{
|
{
|
||||||
m_Value->RestoreState(pile1, bMain);
|
m_Value->RestoreState(pile1, bMain);
|
||||||
|
@ -887,7 +887,7 @@ void CBotSwitch :: RestoreState(CBotStack* &pj, bool bMain)
|
||||||
while ( p != NULL && state-- > 0 )
|
while ( p != NULL && state-- > 0 )
|
||||||
{
|
{
|
||||||
p->RestoreState(pile1, false);
|
p->RestoreState(pile1, false);
|
||||||
p = p->GivNext(); // advance in the list
|
p = p->GetNext(); // advance in the list
|
||||||
}
|
}
|
||||||
|
|
||||||
if( p != NULL )
|
if( p != NULL )
|
||||||
|
@ -923,7 +923,7 @@ CBotInstr* CBotCase::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
inst->SetToken(p);
|
inst->SetToken(p);
|
||||||
if (!IsOfType(p, ID_CASE, ID_DEFAULT)) return NULL; // should never happen
|
if (!IsOfType(p, ID_CASE, ID_DEFAULT)) return NULL; // should never happen
|
||||||
|
|
||||||
if ( pp->GivType() == ID_CASE )
|
if ( pp->GetType() == ID_CASE )
|
||||||
{
|
{
|
||||||
pp = p;
|
pp = p;
|
||||||
inst->m_Value = CBotExprNum::Compile(p, pStack);
|
inst->m_Value = CBotExprNum::Compile(p, pStack);
|
||||||
|
@ -936,7 +936,7 @@ CBotInstr* CBotCase::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
}
|
}
|
||||||
if ( !IsOfType( p, ID_DOTS ))
|
if ( !IsOfType( p, ID_DOTS ))
|
||||||
{
|
{
|
||||||
pStack->SetError( TX_MISDOTS, p->GivStart() );
|
pStack->SetError( TX_MISDOTS, p->GetStart() );
|
||||||
delete inst;
|
delete inst;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -963,7 +963,7 @@ bool CBotCase::CompCase(CBotStack* &pile, int val)
|
||||||
if ( m_Value == NULL ) return true; // "default" case
|
if ( m_Value == NULL ) return true; // "default" case
|
||||||
|
|
||||||
while (!m_Value->Execute(pile)); // puts the value on the correspondent stack (without interruption)
|
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)
|
CBotInstr* CBotBreak::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
{
|
{
|
||||||
CBotToken* pp = p; // preserves at the ^ token (starting position)
|
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
|
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;
|
pp = p;
|
||||||
if ( IsOfType( p, TokenTypVar ) )
|
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 ) )
|
if ( !ChkLvl(inst->m_label, type ) )
|
||||||
{
|
{
|
||||||
delete inst;
|
delete inst;
|
||||||
|
@ -1014,7 +1014,7 @@ CBotInstr* CBotBreak::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
}
|
}
|
||||||
delete inst;
|
delete inst;
|
||||||
|
|
||||||
pStack->SetError(TX_ENDOF, p->GivStart());
|
pStack->SetError(TX_ENDOF, p->GetStart());
|
||||||
return NULL; // no object, the error is on the stack
|
return NULL; // no object, the error is on the stack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1027,7 +1027,7 @@ bool CBotBreak :: Execute(CBotStack* &pj)
|
||||||
|
|
||||||
if ( pile->IfStep() ) return false;
|
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);
|
return pj->Return(pile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1070,7 +1070,7 @@ CBotInstr* CBotTry::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk );
|
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk );
|
||||||
CBotCatch** pn = &inst->m_ListCatch;
|
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);
|
CBotCatch* i = CBotCatch::Compile(p, pStk);
|
||||||
*pn = i;
|
*pn = i;
|
||||||
|
@ -1108,7 +1108,7 @@ bool CBotTry :: Execute(CBotStack* &pj)
|
||||||
CBotStack* pile0 = pj->AddStack2(); // adds an element to the secondary stack
|
CBotStack* pile0 = pj->AddStack2(); // adds an element to the secondary stack
|
||||||
CBotStack* pile2 = pile0->AddStack();
|
CBotStack* pile2 = pile0->AddStack();
|
||||||
|
|
||||||
if ( pile1->GivState() == 0 )
|
if ( pile1->GetState() == 0 )
|
||||||
{
|
{
|
||||||
if ( m_Block->Execute(pile1) )
|
if ( m_Block->Execute(pile1) )
|
||||||
{
|
{
|
||||||
|
@ -1116,7 +1116,7 @@ bool CBotTry :: Execute(CBotStack* &pj)
|
||||||
pile1->SetState(-2); // passes final
|
pile1->SetState(-2); // passes final
|
||||||
}
|
}
|
||||||
|
|
||||||
val = pile1->GivError();
|
val = pile1->GetError();
|
||||||
if ( val == 0 && CBotStack::m_initimer == 0 ) // mode step?
|
if ( val == 0 && CBotStack::m_initimer == 0 ) // mode step?
|
||||||
return false; // does not make the catch
|
return false; // does not make the catch
|
||||||
|
|
||||||
|
@ -1132,8 +1132,8 @@ bool CBotTry :: Execute(CBotStack* &pj)
|
||||||
// see what it returns
|
// see what it returns
|
||||||
|
|
||||||
CBotCatch* pc = m_ListCatch;
|
CBotCatch* pc = m_ListCatch;
|
||||||
int state = (short)pile1->GivState(); // where were we?
|
int state = (short)pile1->GetState(); // where were we?
|
||||||
val = pile2->GivState(); // what error?
|
val = pile2->GetState(); // what error?
|
||||||
pile0->SetState(1); // marking the GetRunPos
|
pile0->SetState(1); // marking the GetRunPos
|
||||||
|
|
||||||
if ( val >= 0 && state > 0 ) while ( pc != NULL )
|
if ( val >= 0 && state > 0 ) while ( pc != NULL )
|
||||||
|
@ -1147,7 +1147,7 @@ bool CBotTry :: Execute(CBotStack* &pj)
|
||||||
}
|
}
|
||||||
if ( --state <= 0 )
|
if ( --state <= 0 )
|
||||||
{
|
{
|
||||||
if ( pile2->GivVal() == true )
|
if ( pile2->GetVal() == true )
|
||||||
{
|
{
|
||||||
// pile0->SetState(1);
|
// pile0->SetState(1);
|
||||||
|
|
||||||
|
@ -1163,15 +1163,15 @@ bool CBotTry :: Execute(CBotStack* &pj)
|
||||||
pc = pc->m_next;
|
pc = pc->m_next;
|
||||||
}
|
}
|
||||||
if ( m_FinalInst != NULL &&
|
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);
|
// pile0->SetState(1);
|
||||||
|
|
||||||
if (!m_FinalInst->Execute(pile2) && pile2->IsOk()) return false;
|
if (!m_FinalInst->Execute(pile2) && pile2->IsOk()) return false;
|
||||||
if (!pile2->IsOk()) return pj->Return(pile2); // keep this exception
|
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);
|
return pj->Return(pile2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1200,7 +1200,7 @@ void CBotTry :: RestoreState(CBotStack* &pj, bool bMain)
|
||||||
if ( pile2 == NULL ) return;
|
if ( pile2 == NULL ) return;
|
||||||
|
|
||||||
m_Block->RestoreState(pile1, bMain);
|
m_Block->RestoreState(pile1, bMain);
|
||||||
if ( pile0->GivState() == 0 )
|
if ( pile0->GetState() == 0 )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1209,8 +1209,8 @@ void CBotTry :: RestoreState(CBotStack* &pj, bool bMain)
|
||||||
// see what it returns
|
// see what it returns
|
||||||
|
|
||||||
CBotCatch* pc = m_ListCatch;
|
CBotCatch* pc = m_ListCatch;
|
||||||
int state = pile1->GivState(); // where were we ?
|
int state = pile1->GetState(); // where were we ?
|
||||||
val = pile2->GivState(); // what error ?
|
val = pile2->GetState(); // what error ?
|
||||||
|
|
||||||
if ( val >= 0 && state > 0 ) while ( pc != NULL )
|
if ( val >= 0 && state > 0 ) while ( pc != NULL )
|
||||||
{
|
{
|
||||||
|
@ -1223,7 +1223,7 @@ void CBotTry :: RestoreState(CBotStack* &pj, bool bMain)
|
||||||
}
|
}
|
||||||
if ( --state <= 0 )
|
if ( --state <= 0 )
|
||||||
{
|
{
|
||||||
if ( pile2->GivVal() == true )
|
if ( pile2->GetVal() == true )
|
||||||
{
|
{
|
||||||
pc->RestoreState(pile2, bMain); // execute the operation
|
pc->RestoreState(pile2, bMain); // execute the operation
|
||||||
return;
|
return;
|
||||||
|
@ -1232,7 +1232,7 @@ void CBotTry :: RestoreState(CBotStack* &pj, bool bMain)
|
||||||
pc = pc->m_next;
|
pc = pc->m_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pile1->GivState() <= -1)
|
if (pile1->GetState() <= -1)
|
||||||
{
|
{
|
||||||
m_FinalInst->RestoreState(pile2, bMain);
|
m_FinalInst->RestoreState(pile2, bMain);
|
||||||
return;
|
return;
|
||||||
|
@ -1263,7 +1263,7 @@ CBotCatch::~CBotCatch()
|
||||||
CBotCatch* CBotCatch::Compile(CBotToken* &p, CBotCStack* pStack)
|
CBotCatch* CBotCatch::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
{
|
{
|
||||||
CBotCatch* inst = new CBotCatch(); // creates the object
|
CBotCatch* inst = new CBotCatch(); // creates the object
|
||||||
pStack->SetStartError(p->GivStart());
|
pStack->SetStartError(p->GetStart());
|
||||||
|
|
||||||
inst->SetToken(p);
|
inst->SetToken(p);
|
||||||
if (!IsOfType(p, ID_CATCH)) return NULL; // should never happen
|
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))
|
if (IsOfType(p, ID_OPENPAR))
|
||||||
{
|
{
|
||||||
inst->m_Cond = CBotExpression::Compile(p, pStack);
|
inst->m_Cond = CBotExpression::Compile(p, pStack);
|
||||||
if (( pStack->GivType() < CBotTypLong ||
|
if (( pStack->GetType() < CBotTypLong ||
|
||||||
pStack->GivTypResult().Eq(CBotTypBoolean) )&& pStack->IsOk() )
|
pStack->GetTypResult().Eq(CBotTypBoolean) )&& pStack->IsOk() )
|
||||||
{
|
{
|
||||||
if (IsOfType(p, ID_CLOSEPAR))
|
if (IsOfType(p, ID_CLOSEPAR))
|
||||||
{
|
{
|
||||||
|
@ -1280,11 +1280,11 @@ CBotCatch* CBotCatch::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
if ( pStack->IsOk() )
|
if ( pStack->IsOk() )
|
||||||
return inst; // return an object to the application
|
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
|
delete inst; // error, frees up
|
||||||
return NULL; // no object, the error is on the stack
|
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 ( !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);
|
CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypBoolean);
|
||||||
var->SetValInt( pile->GivVal() == val );
|
var->SetValInt( pile->GetVal() == val );
|
||||||
pile->SetVar(var); // calls on the stack
|
pile->SetVar(var); // calls on the stack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1342,7 +1342,7 @@ CBotThrow::~CBotThrow()
|
||||||
|
|
||||||
CBotInstr* CBotThrow::Compile(CBotToken* &p, CBotCStack* pStack)
|
CBotInstr* CBotThrow::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
{
|
{
|
||||||
pStack->SetStartError(p->GivStart());
|
pStack->SetStartError(p->GetStart());
|
||||||
|
|
||||||
CBotThrow* inst = new CBotThrow(); // creates the object
|
CBotThrow* inst = new CBotThrow(); // creates the object
|
||||||
inst->SetToken(p);
|
inst->SetToken(p);
|
||||||
|
@ -1353,7 +1353,7 @@ CBotInstr* CBotThrow::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
|
||||||
inst->m_Value = CBotExpression::Compile( p, 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
|
return inst; // return an object to the application
|
||||||
}
|
}
|
||||||
|
@ -1370,7 +1370,7 @@ bool CBotThrow :: Execute(CBotStack* &pj)
|
||||||
CBotStack* pile = pj->AddStack(this);
|
CBotStack* pile = pj->AddStack(this);
|
||||||
// if ( pile == EOX ) return true;
|
// if ( pile == EOX ) return true;
|
||||||
|
|
||||||
if ( pile->GivState() == 0 )
|
if ( pile->GetState() == 0 )
|
||||||
{
|
{
|
||||||
if ( !m_Value->Execute(pile) ) return false;
|
if ( !m_Value->Execute(pile) ) return false;
|
||||||
pile->IncState();
|
pile->IncState();
|
||||||
|
@ -1378,7 +1378,7 @@ bool CBotThrow :: Execute(CBotStack* &pj)
|
||||||
|
|
||||||
if ( pile->IfStep() ) return false;
|
if ( pile->IfStep() ) return false;
|
||||||
|
|
||||||
int val = pile->GivVal();
|
int val = pile->GetVal();
|
||||||
if ( val < 0 ) val = TX_BADTHROW;
|
if ( val < 0 ) val = TX_BADTHROW;
|
||||||
pile->SetError( val, &m_token );
|
pile->SetError( val, &m_token );
|
||||||
return pj->Return( pile );
|
return pj->Return( pile );
|
||||||
|
@ -1391,7 +1391,7 @@ void CBotThrow :: RestoreState(CBotStack* &pj, bool bMain)
|
||||||
CBotStack* pile = pj->RestoreStack(this);
|
CBotStack* pile = pj->RestoreStack(this);
|
||||||
if ( pile == NULL ) return;
|
if ( pile == NULL ) return;
|
||||||
|
|
||||||
if ( pile->GivState() == 0 )
|
if ( pile->GetState() == 0 )
|
||||||
{
|
{
|
||||||
m_Value->RestoreState(pile, bMain);
|
m_Value->RestoreState(pile, bMain);
|
||||||
return;
|
return;
|
||||||
|
@ -1425,7 +1425,7 @@ CBotInstr* CBotStartDebugDD::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
|
||||||
bool CBotStartDebugDD :: Execute(CBotStack* &pj)
|
bool CBotStartDebugDD :: Execute(CBotStack* &pj)
|
||||||
{
|
{
|
||||||
CBotProgram* p = pj->GivBotCall();
|
CBotProgram* p = pj->GetBotCall();
|
||||||
p->m_bDebugDD = true;
|
p->m_bDebugDD = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -68,25 +68,25 @@ bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exceptio
|
||||||
if ( pVar == NULL ) return true;
|
if ( pVar == NULL ) return true;
|
||||||
|
|
||||||
// must be a string
|
// 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
|
PrepareFilename(filename); //DR
|
||||||
|
|
||||||
// there may be a second parameter
|
// there may be a second parameter
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
if ( pVar != NULL )
|
if ( pVar != NULL )
|
||||||
{
|
{
|
||||||
// recovers the mode
|
// recovers the mode
|
||||||
mode = pVar->GivValString();
|
mode = pVar->GetValString();
|
||||||
if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return false; }
|
if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return false; }
|
||||||
|
|
||||||
// no third parameter, only two or one possible
|
// 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
|
// save the file name
|
||||||
pVar = pThis->GivItem("filename");
|
pVar = pThis->GetItem("filename");
|
||||||
pVar->SetValString(filename);
|
pVar->SetValString(filename);
|
||||||
|
|
||||||
if ( ! mode.IsEmpty() )
|
if ( ! mode.IsEmpty() )
|
||||||
|
@ -98,7 +98,7 @@ bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exceptio
|
||||||
m_CompteurFileOpen ++;
|
m_CompteurFileOpen ++;
|
||||||
|
|
||||||
// save the handle of file
|
// save the handle of file
|
||||||
pVar = pThis->GivItem("handle");
|
pVar = pThis->GetItem("handle");
|
||||||
pVar->SetValInt((long)pFile);
|
pVar->SetValInt((long)pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,18 +112,18 @@ CBotTypResult cfconstruct (CBotVar* pThis, CBotVar* &pVar)
|
||||||
if ( pVar == NULL ) return CBotTypResult( 0 );
|
if ( pVar == NULL ) return CBotTypResult( 0 );
|
||||||
|
|
||||||
// must be a string
|
// must be a string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GetType() != CBotTypString )
|
||||||
return CBotTypResult( CBotErrBadString );
|
return CBotTypResult( CBotErrBadString );
|
||||||
|
|
||||||
// there may be a second parameter
|
// there may be a second parameter
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
if ( pVar != NULL )
|
if ( pVar != NULL )
|
||||||
{
|
{
|
||||||
// must be a string
|
// must be a string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GetType() != CBotTypString )
|
||||||
return CBotTypResult( CBotErrBadString );
|
return CBotTypResult( CBotErrBadString );
|
||||||
// no third parameter
|
// 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)
|
// 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)
|
bool rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
{
|
{
|
||||||
// retrieves the element "handle"
|
// retrieves the element "handle"
|
||||||
pVar = pThis->GivItem("handle");
|
pVar = pThis->GetItem("handle");
|
||||||
|
|
||||||
// not open? no problem
|
// 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);
|
fclose(pFile);
|
||||||
m_CompteurFileOpen --;
|
m_CompteurFileOpen --;
|
||||||
|
|
||||||
|
@ -162,38 +162,38 @@ bool rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
|
if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
|
||||||
|
|
||||||
// must be a string
|
// 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
|
// there may be a second parameter
|
||||||
if ( pVar->GivNext() != NULL )
|
if ( pVar->GetNext() != NULL )
|
||||||
{
|
{
|
||||||
// in this case the first parameter is the file name
|
// in this case the first parameter is the file name
|
||||||
CBotString filename = pVar->GivValString();
|
CBotString filename = pVar->GetValString();
|
||||||
PrepareFilename(filename); //DR
|
PrepareFilename(filename); //DR
|
||||||
|
|
||||||
// saves the file name
|
// saves the file name
|
||||||
CBotVar* pVar2 = pThis->GivItem("filename");
|
CBotVar* pVar2 = pThis->GetItem("filename");
|
||||||
pVar2->SetValString(filename);
|
pVar2->SetValString(filename);
|
||||||
|
|
||||||
// next parameter is the mode
|
// 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; }
|
if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return false; }
|
||||||
|
|
||||||
// No third parameter
|
// No third parameter
|
||||||
if ( pVar->GivNext() != NULL ) { Exception = CBotErrOverParam; return false; }
|
if ( pVar->GetNext() != NULL ) { Exception = CBotErrOverParam; return false; }
|
||||||
|
|
||||||
// retrieves the element "handle"
|
// retrieves the element "handle"
|
||||||
pVar = pThis->GivItem("handle");
|
pVar = pThis->GetItem("handle");
|
||||||
|
|
||||||
// which must not be initialized
|
// 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
|
// contains filename
|
||||||
pVar = pThis->GivItem("filename");
|
pVar = pThis->GetItem("filename");
|
||||||
CBotString filename = pVar->GivValString();
|
CBotString filename = pVar->GetValString();
|
||||||
|
|
||||||
PrepareFilename(filename); //DD! (if the name was assigned by h.filename = "...";
|
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 ++;
|
m_CompteurFileOpen ++;
|
||||||
|
|
||||||
// saves the handle of file
|
// saves the handle of file
|
||||||
pVar = pThis->GivItem("handle");
|
pVar = pThis->GetItem("handle");
|
||||||
pVar->SetValInt((long)pFile);
|
pVar->SetValInt((long)pFile);
|
||||||
|
|
||||||
pResult->SetValInt(true); //DR
|
pResult->SetValInt(true); //DR
|
||||||
|
@ -222,19 +222,19 @@ CBotTypResult cfopen (CBotVar* pThis, CBotVar* &pVar)
|
||||||
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
|
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
|
||||||
|
|
||||||
// must be a string
|
// must be a string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GetType() != CBotTypString )
|
||||||
return CBotTypResult( CBotErrBadString );
|
return CBotTypResult( CBotErrBadString );
|
||||||
|
|
||||||
// there may be a second parameter
|
// there may be a second parameter
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
if ( pVar != NULL )
|
if ( pVar != NULL )
|
||||||
{
|
{
|
||||||
// must be a string
|
// must be a string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GetType() != CBotTypString )
|
||||||
return CBotTypResult( CBotErrBadString );
|
return CBotTypResult( CBotErrBadString );
|
||||||
|
|
||||||
// no third parameter
|
// no third parameter
|
||||||
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
|
if ( pVar->GetNext() != NULL ) return CBotTypResult( CBotErrOverParam );
|
||||||
}
|
}
|
||||||
|
|
||||||
// the result is of type bool
|
// 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;
|
if ( pVar != NULL ) return CBotErrOverParam;
|
||||||
|
|
||||||
// retrieves the element "handle"
|
// 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);
|
fclose(pFile);
|
||||||
m_CompteurFileOpen --;
|
m_CompteurFileOpen --;
|
||||||
|
|
||||||
|
@ -283,16 +283,16 @@ bool rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
|
if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
|
||||||
|
|
||||||
// must be a string
|
// 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"
|
//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);
|
int res = fputs(param+CBotString("\n"), pFile);
|
||||||
|
|
||||||
|
@ -309,10 +309,10 @@ CBotTypResult cfwrite (CBotVar* pThis, CBotVar* &pVar)
|
||||||
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
|
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
|
||||||
|
|
||||||
// must be a string
|
// must be a string
|
||||||
if ( pVar->GivType() != CBotTypString ) return CBotTypResult( CBotErrBadString );
|
if ( pVar->GetType() != CBotTypString ) return CBotTypResult( CBotErrBadString );
|
||||||
|
|
||||||
// no other parameter
|
// no other parameter
|
||||||
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
|
if ( pVar->GetNext() != NULL ) return CBotTypResult( CBotErrOverParam );
|
||||||
|
|
||||||
// function returns "void" result
|
// function returns "void" result
|
||||||
return CBotTypResult( 0 );
|
return CBotTypResult( 0 );
|
||||||
|
@ -327,11 +327,11 @@ bool rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
|
if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
|
||||||
|
|
||||||
//retrieves the element "handle"
|
//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];
|
char chaine[2000];
|
||||||
int i;
|
int i;
|
||||||
|
@ -368,11 +368,11 @@ bool rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
|
if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
|
||||||
|
|
||||||
// retrieves the element "handle"
|
// 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 ) );
|
pResult->SetValInt( feof( pFile ) );
|
||||||
|
|
||||||
|
|
|
@ -26,16 +26,16 @@ bool rStrLen( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||||
|
|
||||||
// to be a string
|
// 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
|
// 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
|
// get the contents of the string
|
||||||
CBotString s = pVar->GivValString();
|
CBotString s = pVar->GetValString();
|
||||||
|
|
||||||
// puts the length of the stack
|
// puts the length of the stack
|
||||||
pResult->SetValInt( s.GivLength() );
|
pResult->SetValInt( s.GetLength() );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,11 +48,11 @@ CBotTypResult cIntStr( CBotVar* &pVar, void* pUser )
|
||||||
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
||||||
|
|
||||||
// to be a string
|
// to be a string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GetType() != CBotTypString )
|
||||||
return CBotTypResult( TX_BADPARAM );
|
return CBotTypResult( TX_BADPARAM );
|
||||||
|
|
||||||
// no second parameter
|
// 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
|
// the end result is an integer
|
||||||
return CBotTypResult( CBotTypInt );
|
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; }
|
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||||
|
|
||||||
// to be a string
|
// 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
|
// get the contents of the string
|
||||||
CBotString s = pVar->GivValString();
|
CBotString s = pVar->GetValString();
|
||||||
|
|
||||||
// it takes a second parameter
|
// it takes a second parameter
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||||
|
|
||||||
// which must be a number
|
// 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
|
// retrieves this number
|
||||||
int n = pVar->GivValInt();
|
int n = pVar->GetValInt();
|
||||||
|
|
||||||
// no third parameter
|
// 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
|
// takes the interesting part
|
||||||
s = s.Left( n );
|
s = s.Left( n );
|
||||||
|
@ -103,19 +103,19 @@ CBotTypResult cStrStrInt( CBotVar* &pVar, void* pUser )
|
||||||
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
||||||
|
|
||||||
// to be a string
|
// to be a string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GetType() != CBotTypString )
|
||||||
return CBotTypResult( TX_BADSTRING );
|
return CBotTypResult( TX_BADSTRING );
|
||||||
|
|
||||||
// it takes a second parameter
|
// it takes a second parameter
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
||||||
|
|
||||||
// which must be a number
|
// which must be a number
|
||||||
if ( pVar->GivType() > CBotTypDouble )
|
if ( pVar->GetType() > CBotTypDouble )
|
||||||
return CBotTypResult( TX_BADNUM );
|
return CBotTypResult( TX_BADNUM );
|
||||||
|
|
||||||
// no third parameter
|
// 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
|
// the end result is a string
|
||||||
return CBotTypResult( CBotTypString );
|
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; }
|
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||||
|
|
||||||
// to be a string
|
// 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
|
// get the contents of the string
|
||||||
CBotString s = pVar->GivValString();
|
CBotString s = pVar->GetValString();
|
||||||
|
|
||||||
// it takes a second parameter
|
// it takes a second parameter
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||||
|
|
||||||
// which must be a number
|
// 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
|
// retrieves this number
|
||||||
int n = pVar->GivValInt();
|
int n = pVar->GetValInt();
|
||||||
|
|
||||||
// no third parameter
|
// 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
|
// takes the interesting part
|
||||||
s = s.Right( n );
|
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; }
|
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||||
|
|
||||||
// to be a string
|
// 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
|
// get the contents of the string
|
||||||
CBotString s = pVar->GivValString();
|
CBotString s = pVar->GetValString();
|
||||||
|
|
||||||
// it takes a second parameter
|
// it takes a second parameter
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||||
|
|
||||||
// which must be a number
|
// 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
|
// retrieves this number
|
||||||
int n = pVar->GivValInt();
|
int n = pVar->GetValInt();
|
||||||
|
|
||||||
// third parameter optional
|
// third parameter optional
|
||||||
if ( pVar->GivNext() != NULL )
|
if ( pVar->GetNext() != NULL )
|
||||||
{
|
{
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
|
|
||||||
// which must be a number
|
// 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
|
// retrieves this number
|
||||||
int l = pVar->GivValInt();
|
int l = pVar->GetValInt();
|
||||||
|
|
||||||
// but no fourth parameter
|
// 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
|
// takes the interesting part
|
||||||
s = s.Mid( n, l );
|
s = s.Mid( n, l );
|
||||||
|
@ -217,28 +217,28 @@ CBotTypResult cStrStrIntInt( CBotVar* &pVar, void* pUser )
|
||||||
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
||||||
|
|
||||||
// to be a string
|
// to be a string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GetType() != CBotTypString )
|
||||||
return CBotTypResult( TX_BADSTRING );
|
return CBotTypResult( TX_BADSTRING );
|
||||||
|
|
||||||
// it takes a second parameter
|
// it takes a second parameter
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
||||||
|
|
||||||
// which must be a number
|
// which must be a number
|
||||||
if ( pVar->GivType() > CBotTypDouble )
|
if ( pVar->GetType() > CBotTypDouble )
|
||||||
return CBotTypResult( TX_BADNUM );
|
return CBotTypResult( TX_BADNUM );
|
||||||
|
|
||||||
// third parameter optional
|
// third parameter optional
|
||||||
if ( pVar->GivNext() != NULL )
|
if ( pVar->GetNext() != NULL )
|
||||||
{
|
{
|
||||||
|
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
// which must be a number
|
// which must be a number
|
||||||
if ( pVar->GivType() > CBotTypDouble )
|
if ( pVar->GetType() > CBotTypDouble )
|
||||||
return CBotTypResult( TX_BADNUM );
|
return CBotTypResult( TX_BADNUM );
|
||||||
|
|
||||||
// no fourth parameter
|
// 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
|
// 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; }
|
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||||
|
|
||||||
// to be a string
|
// 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
|
// get the contents of the string
|
||||||
CBotString s = pVar->GivValString();
|
CBotString s = pVar->GetValString();
|
||||||
|
|
||||||
// but no second parameter
|
// 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
|
// puts the value on the stack
|
||||||
pResult->SetValFloat( val );
|
pResult->SetValFloat( val );
|
||||||
|
@ -279,11 +279,11 @@ CBotTypResult cFloatStr( CBotVar* &pVar, void* pUser )
|
||||||
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
||||||
|
|
||||||
// to be a string
|
// to be a string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GetType() != CBotTypString )
|
||||||
return CBotTypResult( TX_BADSTRING );
|
return CBotTypResult( TX_BADSTRING );
|
||||||
|
|
||||||
// no second parameter
|
// 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
|
// the end result is a number
|
||||||
return CBotTypResult( CBotTypFloat );
|
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; }
|
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||||
|
|
||||||
// to be a string
|
// 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
|
// get the contents of the string
|
||||||
CBotString s = pVar->GivValString();
|
CBotString s = pVar->GetValString();
|
||||||
|
|
||||||
// it takes a second parameter
|
// it takes a second parameter
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||||
|
|
||||||
// to be a string
|
// 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
|
// retrieves this number
|
||||||
CBotString s2 = pVar->GivValString();
|
CBotString s2 = pVar->GetValString();
|
||||||
|
|
||||||
// no third parameter
|
// 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
|
// puts the result on the stack
|
||||||
int res = s.Find(s2);
|
int res = s.Find(s2);
|
||||||
|
@ -333,19 +333,19 @@ CBotTypResult cIntStrStr( CBotVar* &pVar, void* pUser )
|
||||||
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
||||||
|
|
||||||
// to be a string
|
// to be a string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GetType() != CBotTypString )
|
||||||
return CBotTypResult( TX_BADSTRING );
|
return CBotTypResult( TX_BADSTRING );
|
||||||
|
|
||||||
// it takes a second parameter
|
// it takes a second parameter
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
||||||
|
|
||||||
// to be a string
|
// to be a string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GetType() != CBotTypString )
|
||||||
return CBotTypResult( TX_BADSTRING );
|
return CBotTypResult( TX_BADSTRING );
|
||||||
|
|
||||||
// no third parameter
|
// 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
|
// the end result is a number
|
||||||
return CBotTypResult( CBotTypInt );
|
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; }
|
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||||
|
|
||||||
// to be a string
|
// 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
|
// get the contents of the string
|
||||||
CBotString s = pVar->GivValString();
|
CBotString s = pVar->GetValString();
|
||||||
|
|
||||||
// but no second parameter
|
// but no second parameter
|
||||||
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
|
if ( pVar->GetNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
|
||||||
|
|
||||||
|
|
||||||
s.MakeUpper();
|
s.MakeUpper();
|
||||||
|
@ -385,13 +385,13 @@ bool rStrLower( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||||
|
|
||||||
// to be a string
|
// 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
|
// get the contents of the string
|
||||||
CBotString s = pVar->GivValString();
|
CBotString s = pVar->GetValString();
|
||||||
|
|
||||||
// but no second parameter
|
// but no second parameter
|
||||||
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
|
if ( pVar->GetNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
|
||||||
|
|
||||||
|
|
||||||
s.MakeLower();
|
s.MakeLower();
|
||||||
|
@ -410,11 +410,11 @@ CBotTypResult cStrStr( CBotVar* &pVar, void* pUser )
|
||||||
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
if ( pVar == NULL ) return CBotTypResult( TX_LOWPARAM );
|
||||||
|
|
||||||
// to be a string
|
// to be a string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GetType() != CBotTypString )
|
||||||
return CBotTypResult( TX_BADSTRING );
|
return CBotTypResult( TX_BADSTRING );
|
||||||
|
|
||||||
// no second parameter
|
// 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
|
// the end result is a string
|
||||||
return CBotTypResult( CBotTypString );
|
return CBotTypResult( CBotTypString );
|
||||||
|
|
|
@ -50,7 +50,7 @@ uint ThreadProc(ThreadInfo *info)
|
||||||
int level = 0;
|
int level = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
CBotVar* t = info->m_pProg->GivStackVars(FN, level--);
|
CBotVar* t = info->m_pProg->GetStackVars(FN, level--);
|
||||||
if ( FN != FunctionName ) break;
|
if ( FN != FunctionName ) break;
|
||||||
if ( t != NULL )
|
if ( t != NULL )
|
||||||
{
|
{
|
||||||
|
@ -59,8 +59,8 @@ uint ThreadProc(ThreadInfo *info)
|
||||||
{
|
{
|
||||||
if (s.IsEmpty()) s+= "Stack -> ";
|
if (s.IsEmpty()) s+= "Stack -> ";
|
||||||
else s+= " , ";
|
else s+= " , ";
|
||||||
s += t->GivValString();
|
s += t->GetValString();
|
||||||
t = t->GivNext();
|
t = t->GetNext();
|
||||||
}
|
}
|
||||||
AfxMessageBox(s);
|
AfxMessageBox(s);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ uint ThreadProc(ThreadInfo *info)
|
||||||
{
|
{
|
||||||
std::cout << "\nInterrupt\n";
|
std::cout << "\nInterrupt\n";
|
||||||
}
|
}
|
||||||
else if (info->m_pProg->GivError() == 0)
|
else if (info->m_pProg->GetError() == 0)
|
||||||
{
|
{
|
||||||
time(&t1);
|
time(&t1);
|
||||||
double prog_time = difftime(t0,t1);
|
double prog_time = difftime(t0,t1);
|
||||||
|
@ -98,7 +98,7 @@ long CBotConsole::EndProg()
|
||||||
if (m_pProg->GetError(m_code, m_start, m_end))
|
if (m_pProg->GetError(m_code, m_start, m_end))
|
||||||
{
|
{
|
||||||
CBotString TextError;
|
CBotString TextError;
|
||||||
TextError = CBotProgram::GivErrorText(m_code);
|
TextError = CBotProgram::GetErrorText(m_code);
|
||||||
std::cout << TextError;
|
std::cout << TextError;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ void CBotConsole::OnOK()
|
||||||
if ( m_pProg->GetError(err, start, end) )
|
if ( m_pProg->GetError(err, start, end) )
|
||||||
{
|
{
|
||||||
CBotString TextError;
|
CBotString TextError;
|
||||||
TextError = CBotProgram::GivErrorText(err);
|
TextError = CBotProgram::GetErrorText(err);
|
||||||
std::cout << TextError;
|
std::cout << TextError;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ bool CBotConsole::OnInitDialog()
|
||||||
// CDialog::OnInitDialog();
|
// CDialog::OnInitDialog();
|
||||||
|
|
||||||
std::cout << "Following functions are availible:\n";
|
std::cout << "Following functions are availible:\n";
|
||||||
for ( int i = 0; i < m_pListe->GivSize(); i++ )
|
for ( int i = 0; i < m_pListe->GetSize(); i++ )
|
||||||
{
|
{
|
||||||
CBotString x = (*m_pListe)[i] + CBotString("\n");
|
CBotString x = (*m_pListe)[i] + CBotString("\n");
|
||||||
std::cout << x;
|
std::cout << x;
|
||||||
|
|
|
@ -46,18 +46,18 @@ void CBotDoc::OnRun()
|
||||||
delete m_pProg;
|
delete m_pProg;
|
||||||
m_pProg = NULL;
|
m_pProg = NULL;
|
||||||
|
|
||||||
TextError = CBotProgram::GivErrorText( code );
|
TextError = CBotProgram::GetErrorText( code );
|
||||||
std::cout << TextError << std::endl;
|
std::cout << TextError << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_Liste.GivSize() == 0 )
|
if( m_Liste.GetSize() == 0 )
|
||||||
{
|
{
|
||||||
std::cout << "No function marked \"extern\" !\n";
|
std::cout << "No function marked \"extern\" !\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( int i = 0; i < m_Liste.GivSize(); i++ )
|
for ( int i = 0; i < m_Liste.GetSize(); i++ )
|
||||||
{
|
{
|
||||||
int start, stop;
|
int start, stop;
|
||||||
m_pProg->GetPosition(m_Liste[i], start, stop, GetPosNom, GetPosParam);
|
m_pProg->GetPosition(m_Liste[i], start, stop, GetPosNom, GetPosParam);
|
||||||
|
@ -76,7 +76,7 @@ void CBotDoc::OnRun()
|
||||||
// {
|
// {
|
||||||
// std::string TextError;
|
// std::string TextError;
|
||||||
//
|
//
|
||||||
// TextError = m_pProg->GivErrorText( dlg.m_code );
|
// TextError = m_pProg->GetErrorText( dlg.m_code );
|
||||||
//
|
//
|
||||||
// std::cout <<TextError;
|
// std::cout <<TextError;
|
||||||
// }
|
// }
|
||||||
|
@ -105,7 +105,7 @@ bool CBotDoc::Compile()
|
||||||
// m_pEdit->SetSel( start, end );
|
// m_pEdit->SetSel( start, end );
|
||||||
// m_pEdit->SetFocus(); // higlights part of problem
|
// m_pEdit->SetFocus(); // higlights part of problem
|
||||||
|
|
||||||
TextError = CBotProgram::GivErrorText( code );
|
TextError = CBotProgram::GetErrorText( code );
|
||||||
std::cout << TextError ;
|
std::cout << TextError ;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -6,20 +6,20 @@ void rMajObject( CBotVar* pThis, void* pUser )
|
||||||
{
|
{
|
||||||
if (!pThis->IsElemOfClass("object"))
|
if (!pThis->IsElemOfClass("object"))
|
||||||
return ;
|
return ;
|
||||||
CBotVar* pPos = pThis->GivItem("position");
|
CBotVar* pPos = pThis->GetItem("position");
|
||||||
CBotVar* pX = pPos->GivItem("x");
|
CBotVar* pX = pPos->GetItem("x");
|
||||||
CBotVar* pY = pPos->GivItem("y");
|
CBotVar* pY = pPos->GetItem("y");
|
||||||
CBotVar* pZ = pPos->GivItem("z");
|
CBotVar* pZ = pPos->GetItem("z");
|
||||||
// CBotVar* pPt = pThis->GivItem("transport");
|
// CBotVar* pPt = pThis->GetItem("transport");
|
||||||
|
|
||||||
CBotString p = pX->GivValString();
|
CBotString p = pX->GetValString();
|
||||||
|
|
||||||
// pX->SetValFloat( pUser == (void*)1 ? (float)12.5 : (float)44.4 );
|
// pX->SetValFloat( pUser == (void*)1 ? (float)12.5 : (float)44.4 );
|
||||||
pZ->SetValFloat( (float)0 );
|
pZ->SetValFloat( (float)0 );
|
||||||
pY->SetValFloat( (float)-3.33 );
|
pY->SetValFloat( (float)-3.33 );
|
||||||
pX->SetValFloat( pX->GivValFloat() + 10 ) ;
|
pX->SetValFloat( pX->GetValFloat() + 10 ) ;
|
||||||
|
|
||||||
// pX = pThis->GivItem( "xx" );
|
// pX = pThis->GetItem( "xx" );
|
||||||
// pX->SetValFloat( (float)22 );
|
// pX->SetValFloat( (float)22 );
|
||||||
|
|
||||||
// crée une instance sur une classe object
|
// crée une instance sur une classe object
|
||||||
|
|
|
@ -33,16 +33,16 @@ bool rShow( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
|
||||||
{
|
{
|
||||||
string::string ss;
|
string::string ss;
|
||||||
|
|
||||||
ss.LoadString( TX_TYPENAMES + pVar->GivType() );
|
ss.LoadString( TX_TYPENAMES + pVar->GetType() );
|
||||||
s += ss + " ";
|
s += ss + " ";
|
||||||
|
|
||||||
ss = pVar->GivName();
|
ss = pVar->GetName();
|
||||||
if (ss.IsEmpty()) ss = "<sans nom>";
|
if (ss.IsEmpty()) ss = "<sans nom>";
|
||||||
s += ss + " = ";
|
s += ss + " = ";
|
||||||
|
|
||||||
s += pVar->GivValString();
|
s += pVar->GetValString();
|
||||||
s += "\n";
|
s += "\n";
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
AfxMessageBox(s, MB_OK|MB_ICONINFORMATION);
|
AfxMessageBox(s, MB_OK|MB_ICONINFORMATION);
|
||||||
|
@ -70,8 +70,8 @@ bool rPrintLn( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
|
||||||
while ( pVar != NULL )
|
while ( pVar != NULL )
|
||||||
{
|
{
|
||||||
if ( !s.empty() ) s += " ";
|
if ( !s.empty() ) s += " ";
|
||||||
s += pVar->GivValString();
|
s += pVar->GetValString();
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
}
|
}
|
||||||
s += "\n";
|
s += "\n";
|
||||||
|
|
||||||
|
@ -85,8 +85,8 @@ bool rPrint( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
|
||||||
while ( pVar != NULL )
|
while ( pVar != NULL )
|
||||||
{
|
{
|
||||||
if ( !s.empty() ) s += " ";
|
if ( !s.empty() ) s += " ";
|
||||||
s += pVar->GivValString();
|
s += pVar->GetValString();
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
}
|
}
|
||||||
s += " ";
|
s += " ";
|
||||||
std::cout << s;
|
std::cout << s;
|
||||||
|
@ -107,13 +107,13 @@ bool rCPoint( CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception )
|
||||||
{
|
{
|
||||||
if ( pVar == NULL )return true; // constructor with no parameters is ok
|
if ( pVar == NULL )return true; // constructor with no parameters is ok
|
||||||
|
|
||||||
CBotVar* pX = pThis->GivItem("x");
|
CBotVar* pX = pThis->GetItem("x");
|
||||||
pX->SetValFloat( pVar->GivValFloat() );
|
pX->SetValFloat( pVar->GetValFloat() );
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
|
|
||||||
CBotVar* pY = pThis->GivItem("y");
|
CBotVar* pY = pThis->GetItem("y");
|
||||||
pY->SetValFloat( pVar->GivValFloat() );
|
pY->SetValFloat( pVar->GetValFloat() );
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
|
|
||||||
return true; // pas d'interruption
|
return true; // pas d'interruption
|
||||||
}
|
}
|
||||||
|
@ -124,14 +124,14 @@ CBotTypResult cCPoint( CBotVar* pThis, CBotVar* &pVar)
|
||||||
if ( pVar == NULL ) return CBotTypResult(0);
|
if ( pVar == NULL ) return CBotTypResult(0);
|
||||||
|
|
||||||
// numeric type of parameter please
|
// numeric type of parameter please
|
||||||
if ( pVar->GivType() > CBotTypDouble ) return CBotTypResult(5011);
|
if ( pVar->GetType() > CBotTypDouble ) return CBotTypResult(5011);
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
|
|
||||||
// there must be a second parameter
|
// there must be a second parameter
|
||||||
if ( pVar == NULL ) return 5028;
|
if ( pVar == NULL ) return 5028;
|
||||||
// also numeric
|
// also numeric
|
||||||
if ( pVar->GivType() > CBotTypDouble )return CBotTypResult(5011);
|
if ( pVar->GetType() > CBotTypDouble )return CBotTypResult(5011);
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
|
|
||||||
// and not more than 2 parameters please
|
// and not more than 2 parameters please
|
||||||
if ( pVar != NULL ) return CBotTypResult(5026);
|
if ( pVar != NULL ) return CBotTypResult(5026);
|
||||||
|
|
|
@ -91,21 +91,21 @@ void CAuto::Start(int param)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Give a type.
|
// Gete a type.
|
||||||
|
|
||||||
bool CAuto::SetType(ObjectType type)
|
bool CAuto::SetType(ObjectType type)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gives a value.
|
// Getes a value.
|
||||||
|
|
||||||
bool CAuto::SetValue(int rank, float value)
|
bool CAuto::SetValue(int rank, float value)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gives the string.
|
// Getes the string.
|
||||||
|
|
||||||
bool CAuto::SetString(char *string)
|
bool CAuto::SetString(char *string)
|
||||||
{
|
{
|
||||||
|
|
|
@ -115,7 +115,7 @@ void CAutoEgg::Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Gives a value.
|
// Getes a value.
|
||||||
|
|
||||||
bool CAutoEgg::SetType(ObjectType type)
|
bool CAutoEgg::SetType(ObjectType type)
|
||||||
{
|
{
|
||||||
|
@ -123,7 +123,7 @@ bool CAutoEgg::SetType(ObjectType type)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gives a value.
|
// Getes a value.
|
||||||
|
|
||||||
bool CAutoEgg::SetValue(int rank, float value)
|
bool CAutoEgg::SetValue(int rank, float value)
|
||||||
{
|
{
|
||||||
|
@ -132,7 +132,7 @@ bool CAutoEgg::SetValue(int rank, float value)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gives the string.
|
// Getes the string.
|
||||||
|
|
||||||
bool CAutoEgg::SetString(char *string)
|
bool CAutoEgg::SetString(char *string)
|
||||||
{
|
{
|
||||||
|
|
|
@ -201,7 +201,7 @@ bool CMotion::Read(char *line)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Gives the linear vibration.
|
// Getes the linear vibration.
|
||||||
|
|
||||||
void CMotion::SetLinVibration(Math::Vector dir)
|
void CMotion::SetLinVibration(Math::Vector dir)
|
||||||
{
|
{
|
||||||
|
@ -213,7 +213,7 @@ Math::Vector CMotion::RetLinVibration()
|
||||||
return m_linVibration;
|
return m_linVibration;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gives the circular vibration.
|
// Getes the circular vibration.
|
||||||
|
|
||||||
void CMotion::SetCirVibration(Math::Vector dir)
|
void CMotion::SetCirVibration(Math::Vector dir)
|
||||||
{
|
{
|
||||||
|
@ -225,7 +225,7 @@ Math::Vector CMotion::RetCirVibration()
|
||||||
return m_cirVibration;
|
return m_cirVibration;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gives the tilt.
|
// Getes the tilt.
|
||||||
|
|
||||||
void CMotion::SetInclinaison(Math::Vector dir)
|
void CMotion::SetInclinaison(Math::Vector dir)
|
||||||
{
|
{
|
||||||
|
|
|
@ -219,7 +219,7 @@ void CMotionToto::StopDisplayInfo()
|
||||||
m_bQuickPos = true;
|
m_bQuickPos = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gives the position of the mouse.
|
// Getes the position of the mouse.
|
||||||
|
|
||||||
void CMotionToto::SetMousePos(Math::Point pos)
|
void CMotionToto::SetMousePos(Math::Point pos)
|
||||||
{
|
{
|
||||||
|
|
|
@ -131,83 +131,83 @@ void uObject(CBotVar* botThis, void* user)
|
||||||
physics = object->RetPhysics();
|
physics = object->RetPhysics();
|
||||||
|
|
||||||
// Updates the object's type.
|
// Updates the object's type.
|
||||||
pVar = botThis->GivItemList(); // "category"
|
pVar = botThis->GetItemList(); // "category"
|
||||||
type = object->RetType();
|
type = object->RetType();
|
||||||
pVar->SetValInt(type, object->RetName());
|
pVar->SetValInt(type, object->RetName());
|
||||||
|
|
||||||
// Updates the position of the object.
|
// Updates the position of the object.
|
||||||
pVar = pVar->GivNext(); // "position"
|
pVar = pVar->GetNext(); // "position"
|
||||||
if ( object->RetTruck() == 0 )
|
if ( object->RetTruck() == 0 )
|
||||||
{
|
{
|
||||||
pos = object->RetPosition(0);
|
pos = object->RetPosition(0);
|
||||||
pos.y -= object->RetWaterLevel(); // relative to sea level!
|
pos.y -= object->RetWaterLevel(); // relative to sea level!
|
||||||
pSub = pVar->GivItemList(); // "x"
|
pSub = pVar->GetItemList(); // "x"
|
||||||
pSub->SetValFloat(pos.x/g_unit);
|
pSub->SetValFloat(pos.x/g_unit);
|
||||||
pSub = pSub->GivNext(); // "y"
|
pSub = pSub->GetNext(); // "y"
|
||||||
pSub->SetValFloat(pos.z/g_unit);
|
pSub->SetValFloat(pos.z/g_unit);
|
||||||
pSub = pSub->GivNext(); // "z"
|
pSub = pSub->GetNext(); // "z"
|
||||||
pSub->SetValFloat(pos.y/g_unit);
|
pSub->SetValFloat(pos.y/g_unit);
|
||||||
}
|
}
|
||||||
else // object transported?
|
else // object transported?
|
||||||
{
|
{
|
||||||
pSub = pVar->GivItemList(); // "x"
|
pSub = pVar->GetItemList(); // "x"
|
||||||
pSub->SetInit(IS_NAN);
|
pSub->SetInit(IS_NAN);
|
||||||
pSub = pSub->GivNext(); // "y"
|
pSub = pSub->GetNext(); // "y"
|
||||||
pSub->SetInit(IS_NAN);
|
pSub->SetInit(IS_NAN);
|
||||||
pSub = pSub->GivNext(); // "z"
|
pSub = pSub->GetNext(); // "z"
|
||||||
pSub->SetInit(IS_NAN);
|
pSub->SetInit(IS_NAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updates the angle.
|
// Updates the angle.
|
||||||
pos = object->RetAngle(0);
|
pos = object->RetAngle(0);
|
||||||
pos += object->RetInclinaison();
|
pos += object->RetInclinaison();
|
||||||
pVar = pVar->GivNext(); // "orientation"
|
pVar = pVar->GetNext(); // "orientation"
|
||||||
pVar->SetValFloat(360.0f-Math::Mod(pos.y*180.0f/Math::PI, 360.0f));
|
pVar->SetValFloat(360.0f-Math::Mod(pos.y*180.0f/Math::PI, 360.0f));
|
||||||
pVar = pVar->GivNext(); // "pitch"
|
pVar = pVar->GetNext(); // "pitch"
|
||||||
pVar->SetValFloat(pos.z*180.0f/Math::PI);
|
pVar->SetValFloat(pos.z*180.0f/Math::PI);
|
||||||
pVar = pVar->GivNext(); // "roll"
|
pVar = pVar->GetNext(); // "roll"
|
||||||
pVar->SetValFloat(pos.x*180.0f/Math::PI);
|
pVar->SetValFloat(pos.x*180.0f/Math::PI);
|
||||||
|
|
||||||
// Updates the energy level of the object.
|
// Updates the energy level of the object.
|
||||||
pVar = pVar->GivNext(); // "energyLevel"
|
pVar = pVar->GetNext(); // "energyLevel"
|
||||||
value = object->RetEnergy();
|
value = object->RetEnergy();
|
||||||
pVar->SetValFloat(value);
|
pVar->SetValFloat(value);
|
||||||
|
|
||||||
// Updates the shield level of the object.
|
// Updates the shield level of the object.
|
||||||
pVar = pVar->GivNext(); // "shieldLevel"
|
pVar = pVar->GetNext(); // "shieldLevel"
|
||||||
value = object->RetShield();
|
value = object->RetShield();
|
||||||
pVar->SetValFloat(value);
|
pVar->SetValFloat(value);
|
||||||
|
|
||||||
// Updates the temperature of the reactor.
|
// Updates the temperature of the reactor.
|
||||||
pVar = pVar->GivNext(); // "temperature"
|
pVar = pVar->GetNext(); // "temperature"
|
||||||
if ( physics == 0 ) value = 0.0f;
|
if ( physics == 0 ) value = 0.0f;
|
||||||
else value = 1.0f-physics->RetReactorRange();
|
else value = 1.0f-physics->RetReactorRange();
|
||||||
pVar->SetValFloat(value);
|
pVar->SetValFloat(value);
|
||||||
|
|
||||||
// Updates the height above the ground.
|
// Updates the height above the ground.
|
||||||
pVar = pVar->GivNext(); // "altitude"
|
pVar = pVar->GetNext(); // "altitude"
|
||||||
if ( physics == 0 ) value = 0.0f;
|
if ( physics == 0 ) value = 0.0f;
|
||||||
else value = physics->RetFloorHeight();
|
else value = physics->RetFloorHeight();
|
||||||
pVar->SetValFloat(value/g_unit);
|
pVar->SetValFloat(value/g_unit);
|
||||||
|
|
||||||
// Updates the lifetime of the object.
|
// Updates the lifetime of the object.
|
||||||
pVar = pVar->GivNext(); // "lifeTime"
|
pVar = pVar->GetNext(); // "lifeTime"
|
||||||
value = object->RetAbsTime();
|
value = object->RetAbsTime();
|
||||||
pVar->SetValFloat(value);
|
pVar->SetValFloat(value);
|
||||||
|
|
||||||
// Updates the material of the object.
|
// Updates the material of the object.
|
||||||
pVar = pVar->GivNext(); // "material"
|
pVar = pVar->GetNext(); // "material"
|
||||||
iValue = object->RetMaterial();
|
iValue = object->RetMaterial();
|
||||||
pVar->SetValInt(iValue);
|
pVar->SetValInt(iValue);
|
||||||
|
|
||||||
// Updates the type of battery.
|
// Updates the type of battery.
|
||||||
pVar = pVar->GivNext(); // "energyCell"
|
pVar = pVar->GetNext(); // "energyCell"
|
||||||
power = object->RetPower();
|
power = object->RetPower();
|
||||||
if ( power == 0 ) pVar->SetPointer(0);
|
if ( power == 0 ) pVar->SetPointer(0);
|
||||||
else pVar->SetPointer(power->RetBotVar());
|
else pVar->SetPointer(power->RetBotVar());
|
||||||
|
|
||||||
// Updates the transported object's type.
|
// Updates the transported object's type.
|
||||||
pVar = pVar->GivNext(); // "load"
|
pVar = pVar->GetNext(); // "load"
|
||||||
fret = object->RetFret();
|
fret = object->RetFret();
|
||||||
if ( fret == 0 ) pVar->SetPointer(0);
|
if ( fret == 0 ) pVar->SetPointer(0);
|
||||||
else pVar->SetPointer(fret->RetBotVar());
|
else pVar->SetPointer(fret->RetBotVar());
|
||||||
|
@ -1468,7 +1468,7 @@ void CObject::FloorAdjust()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Gives the linear vibration.
|
// Getes the linear vibration.
|
||||||
|
|
||||||
void CObject::SetLinVibration(Math::Vector dir)
|
void CObject::SetLinVibration(Math::Vector dir)
|
||||||
{
|
{
|
||||||
|
@ -1486,7 +1486,7 @@ Math::Vector CObject::RetLinVibration()
|
||||||
return m_linVibration;
|
return m_linVibration;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gives the circular vibration.
|
// Getes the circular vibration.
|
||||||
|
|
||||||
void CObject::SetCirVibration(Math::Vector dir)
|
void CObject::SetCirVibration(Math::Vector dir)
|
||||||
{
|
{
|
||||||
|
@ -1504,7 +1504,7 @@ Math::Vector CObject::RetCirVibration()
|
||||||
return m_cirVibration;
|
return m_cirVibration;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gives the inclination.
|
// Getes the inclination.
|
||||||
|
|
||||||
void CObject::SetInclinaison(Math::Vector dir)
|
void CObject::SetInclinaison(Math::Vector dir)
|
||||||
{
|
{
|
||||||
|
@ -1523,7 +1523,7 @@ Math::Vector CObject::RetInclinaison()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Gives the position of center of the object.
|
// Getes the position of center of the object.
|
||||||
|
|
||||||
void CObject::SetPosition(int part, const Math::Vector &pos)
|
void CObject::SetPosition(int part, const Math::Vector &pos)
|
||||||
{
|
{
|
||||||
|
@ -1649,7 +1649,7 @@ Math::Vector CObject::RetPosition(int part)
|
||||||
return m_objectPart[part].position;
|
return m_objectPart[part].position;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gives the rotation around three axis.
|
// Getes the rotation around three axis.
|
||||||
|
|
||||||
void CObject::SetAngle(int part, const Math::Vector &angle)
|
void CObject::SetAngle(int part, const Math::Vector &angle)
|
||||||
{
|
{
|
||||||
|
@ -1667,7 +1667,7 @@ Math::Vector CObject::RetAngle(int part)
|
||||||
return m_objectPart[part].angle;
|
return m_objectPart[part].angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gives the rotation about the axis Y.
|
// Getes the rotation about the axis Y.
|
||||||
|
|
||||||
void CObject::SetAngleY(int part, float angle)
|
void CObject::SetAngleY(int part, float angle)
|
||||||
{
|
{
|
||||||
|
@ -1680,7 +1680,7 @@ void CObject::SetAngleY(int part, float angle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gives the rotation about the axis X.
|
// Getes the rotation about the axis X.
|
||||||
|
|
||||||
void CObject::SetAngleX(int part, float angle)
|
void CObject::SetAngleX(int part, float angle)
|
||||||
{
|
{
|
||||||
|
@ -1688,7 +1688,7 @@ void CObject::SetAngleX(int part, float angle)
|
||||||
m_objectPart[part].bRotate = true; // it will recalculate the matrices
|
m_objectPart[part].bRotate = true; // it will recalculate the matrices
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gives the rotation about the axis Z.
|
// Getes the rotation about the axis Z.
|
||||||
|
|
||||||
void CObject::SetAngleZ(int part, float angle)
|
void CObject::SetAngleZ(int part, float angle)
|
||||||
{
|
{
|
||||||
|
@ -1712,7 +1712,7 @@ float CObject::RetAngleZ(int part)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Gives the global zoom.
|
// Getes the global zoom.
|
||||||
|
|
||||||
void CObject::SetZoom(int part, float zoom)
|
void CObject::SetZoom(int part, float zoom)
|
||||||
{
|
{
|
||||||
|
@ -7431,7 +7431,7 @@ void CObject::UpdateSelectParticule()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Gives the pointer to the current script execution.
|
// Getes the pointer to the current script execution.
|
||||||
|
|
||||||
void CObject::SetRunScript(CScript* script)
|
void CObject::SetRunScript(CScript* script)
|
||||||
{
|
{
|
||||||
|
@ -7498,7 +7498,7 @@ int CObject::RetDefRank()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Gives the object name for the tooltip.
|
// Getes the object name for the tooltip.
|
||||||
|
|
||||||
bool CObject::GetTooltipName(char* name)
|
bool CObject::GetTooltipName(char* name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -145,25 +145,25 @@ bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exceptio
|
||||||
if ( pVar == NULL ) return true;
|
if ( pVar == NULL ) return true;
|
||||||
|
|
||||||
// must be a character string
|
// must be a character 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);
|
PrepareFilename(filename);
|
||||||
|
|
||||||
// there may be a second parameter
|
// there may be a second parameter
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
if ( pVar != NULL )
|
if ( pVar != NULL )
|
||||||
{
|
{
|
||||||
// recover mode
|
// recover mode
|
||||||
mode = pVar->GivValString();
|
mode = pVar->GetValString();
|
||||||
if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return false; }
|
if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return false; }
|
||||||
|
|
||||||
// no third parameter
|
// no third parameter
|
||||||
if ( pVar->GivNext() != NULL ) { Exception = CBotErrOverParam; return false; }
|
if ( pVar->GetNext() != NULL ) { Exception = CBotErrOverParam; return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// saves the file name
|
// saves the file name
|
||||||
pVar = pThis->GivItem("filename");
|
pVar = pThis->GetItem("filename");
|
||||||
pVar->SetValString(filename);
|
pVar->SetValString(filename);
|
||||||
|
|
||||||
if ( ! mode.IsEmpty() )
|
if ( ! mode.IsEmpty() )
|
||||||
|
@ -175,7 +175,7 @@ bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exceptio
|
||||||
m_CompteurFileOpen ++;
|
m_CompteurFileOpen ++;
|
||||||
|
|
||||||
// save the channel file
|
// save the channel file
|
||||||
pVar = pThis->GivItem("handle");
|
pVar = pThis->GetItem("handle");
|
||||||
pVar->SetValInt((long)pFile);
|
pVar->SetValInt((long)pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,18 +189,18 @@ CBotTypResult cfconstruct (CBotVar* pThis, CBotVar* &pVar)
|
||||||
if ( pVar == NULL ) return CBotTypResult( 0 );
|
if ( pVar == NULL ) return CBotTypResult( 0 );
|
||||||
|
|
||||||
// must be a character string
|
// must be a character string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GetType() != CBotTypString )
|
||||||
return CBotTypResult( CBotErrBadString );
|
return CBotTypResult( CBotErrBadString );
|
||||||
|
|
||||||
// there may be a second parameter
|
// there may be a second parameter
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
if ( pVar != NULL )
|
if ( pVar != NULL )
|
||||||
{
|
{
|
||||||
// which must be a string
|
// which must be a string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GetType() != CBotTypString )
|
||||||
return CBotTypResult( CBotErrBadString );
|
return CBotTypResult( CBotErrBadString );
|
||||||
// no third parameter
|
// no third parameter
|
||||||
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
|
if ( pVar->GetNext() != NULL ) return CBotTypResult( CBotErrOverParam );
|
||||||
}
|
}
|
||||||
|
|
||||||
// the result is void (constructor)
|
// the result is void (constructor)
|
||||||
|
@ -214,12 +214,12 @@ CBotTypResult cfconstruct (CBotVar* pThis, CBotVar* &pVar)
|
||||||
bool rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
bool rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
{
|
{
|
||||||
// retrieve the item "handle"
|
// retrieve the item "handle"
|
||||||
pVar = pThis->GivItem("handle");
|
pVar = pThis->GetItem("handle");
|
||||||
|
|
||||||
// don't open? no problem :)
|
// don't 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);
|
fclose(pFile);
|
||||||
m_CompteurFileOpen --;
|
m_CompteurFileOpen --;
|
||||||
|
|
||||||
|
@ -239,38 +239,38 @@ bool rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
|
if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
|
||||||
|
|
||||||
// which must be a character string
|
// which must be a character string
|
||||||
if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
|
if ( pVar->GetType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
|
||||||
|
|
||||||
// There may be a second parameter
|
// There may be a second parameter
|
||||||
if ( pVar->GivNext() != NULL )
|
if ( pVar->GetNext() != NULL )
|
||||||
{
|
{
|
||||||
// if the first parameter is the file name
|
// if the first parameter is the file name
|
||||||
CBotString filename = pVar->GivValString();
|
CBotString filename = pVar->GetValString();
|
||||||
PrepareFilename(filename);
|
PrepareFilename(filename);
|
||||||
|
|
||||||
// saves the file name
|
// saves the file name
|
||||||
CBotVar* pVar2 = pThis->GivItem("filename");
|
CBotVar* pVar2 = pThis->GetItem("filename");
|
||||||
pVar2->SetValString(filename);
|
pVar2->SetValString(filename);
|
||||||
|
|
||||||
// next parameter is the mode
|
// 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; }
|
if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return false; }
|
||||||
|
|
||||||
// no third parameter
|
// no third parameter
|
||||||
if ( pVar->GivNext() != NULL ) { Exception = CBotErrOverParam; return false; }
|
if ( pVar->GetNext() != NULL ) { Exception = CBotErrOverParam; return false; }
|
||||||
|
|
||||||
// retrieve the item "handle"
|
// retrieve the item "handle"
|
||||||
pVar = pThis->GivItem("handle");
|
pVar = pThis->GetItem("handle");
|
||||||
|
|
||||||
// which must not be initialized
|
// which must not be initialized
|
||||||
if ( pVar->GivInit() == IS_DEF) { Exception = CBotErrFileOpen; return false; }
|
if ( pVar->GetInit() == IS_DEF) { Exception = CBotErrFileOpen; return false; }
|
||||||
|
|
||||||
// file contains the name
|
// file contains the name
|
||||||
pVar = pThis->GivItem("filename");
|
pVar = pThis->GetItem("filename");
|
||||||
CBotString filename = pVar->GivValString();
|
CBotString filename = pVar->GetValString();
|
||||||
|
|
||||||
PrepareFilename(filename); // if the name was h.filename attribute = "...";
|
PrepareFilename(filename); // if the name was h.filename attribute = "...";
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ bool rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
m_CompteurFileOpen ++;
|
m_CompteurFileOpen ++;
|
||||||
|
|
||||||
// Registered the channel file
|
// Registered the channel file
|
||||||
pVar = pThis->GivItem("handle");
|
pVar = pThis->GetItem("handle");
|
||||||
pVar->SetValInt((long)pFile);
|
pVar->SetValInt((long)pFile);
|
||||||
|
|
||||||
pResult->SetValInt(true);
|
pResult->SetValInt(true);
|
||||||
|
@ -299,19 +299,19 @@ CBotTypResult cfopen (CBotVar* pThis, CBotVar* &pVar)
|
||||||
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
|
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
|
||||||
|
|
||||||
// which must be a string
|
// which must be a string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GetType() != CBotTypString )
|
||||||
return CBotTypResult( CBotErrBadString );
|
return CBotTypResult( CBotErrBadString );
|
||||||
|
|
||||||
// there may be a second parameter
|
// there may be a second parameter
|
||||||
pVar = pVar->GivNext();
|
pVar = pVar->GetNext();
|
||||||
if ( pVar != NULL )
|
if ( pVar != NULL )
|
||||||
{
|
{
|
||||||
// which must be a string
|
// which must be a string
|
||||||
if ( pVar->GivType() != CBotTypString )
|
if ( pVar->GetType() != CBotTypString )
|
||||||
return CBotTypResult( CBotErrBadString );
|
return CBotTypResult( CBotErrBadString );
|
||||||
|
|
||||||
// no third parameter
|
// no third parameter
|
||||||
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
|
if ( pVar->GetNext() != NULL ) return CBotTypResult( CBotErrOverParam );
|
||||||
}
|
}
|
||||||
|
|
||||||
// the result is bool
|
// the result is bool
|
||||||
|
@ -328,11 +328,11 @@ bool rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
if ( pVar != NULL ) return CBotErrOverParam;
|
if ( pVar != NULL ) return CBotErrOverParam;
|
||||||
|
|
||||||
// retrieve the item "handle"
|
// retrieve the item "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);
|
fclose(pFile);
|
||||||
m_CompteurFileOpen --;
|
m_CompteurFileOpen --;
|
||||||
|
|
||||||
|
@ -360,16 +360,16 @@ bool rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
|
if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
|
||||||
|
|
||||||
// which must be a character string
|
// which must be a character 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();
|
||||||
|
|
||||||
// retrieve the item "handle"
|
// retrieve the item "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);
|
int res = fputs(param+CBotString("\n"), pFile);
|
||||||
|
|
||||||
|
@ -386,10 +386,10 @@ CBotTypResult cfwrite (CBotVar* pThis, CBotVar* &pVar)
|
||||||
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
|
if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
|
||||||
|
|
||||||
// which must be a character string
|
// which must be a character string
|
||||||
if ( pVar->GivType() != CBotTypString ) return CBotTypResult( CBotErrBadString );
|
if ( pVar->GetType() != CBotTypString ) return CBotTypResult( CBotErrBadString );
|
||||||
|
|
||||||
// no other parameter
|
// no other parameter
|
||||||
if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
|
if ( pVar->GetNext() != NULL ) return CBotTypResult( CBotErrOverParam );
|
||||||
|
|
||||||
// the function returns a void result
|
// the function returns a void result
|
||||||
return CBotTypResult( 0 );
|
return CBotTypResult( 0 );
|
||||||
|
@ -404,11 +404,11 @@ bool rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
|
if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
|
||||||
|
|
||||||
// retrieve the item "handle"
|
// retrieve the item "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];
|
char chaine[2000];
|
||||||
int i;
|
int i;
|
||||||
|
@ -445,11 +445,11 @@ bool rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||||
if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
|
if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
|
||||||
|
|
||||||
// retrieve the item "handle"
|
// retrieve the item "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 ) );
|
pResult->SetValInt( feof( pFile ) );
|
||||||
|
|
||||||
|
@ -516,13 +516,13 @@ CBotTypResult cPoint(CBotVar* pThis, CBotVar* &var)
|
||||||
if ( var == NULL ) return CBotTypResult(0); // ok if no parameter
|
if ( var == NULL ) return CBotTypResult(0); // ok if no parameter
|
||||||
|
|
||||||
// First parameter (x):
|
// First parameter (x):
|
||||||
if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
|
if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
|
||||||
var = var->GivNext();
|
var = var->GetNext();
|
||||||
|
|
||||||
// Second parameter (y):
|
// Second parameter (y):
|
||||||
if ( var == NULL ) return CBotTypResult(CBotErrLowParam);
|
if ( var == NULL ) return CBotTypResult(CBotErrLowParam);
|
||||||
if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
|
if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
|
||||||
var = var->GivNext();
|
var = var->GetNext();
|
||||||
|
|
||||||
// Third parameter (z):
|
// Third parameter (z):
|
||||||
if ( var == NULL ) // only 2 parameters?
|
if ( var == NULL ) // only 2 parameters?
|
||||||
|
@ -530,8 +530,8 @@ CBotTypResult cPoint(CBotVar* pThis, CBotVar* &var)
|
||||||
return CBotTypResult(0); // this function returns void
|
return CBotTypResult(0); // this function returns void
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
|
if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
|
||||||
var = var->GivNext();
|
var = var->GetNext();
|
||||||
if ( var != NULL ) return CBotTypResult(CBotErrOverParam);
|
if ( var != NULL ) return CBotTypResult(CBotErrOverParam);
|
||||||
|
|
||||||
return CBotTypResult(0); // this function returns void
|
return CBotTypResult(0); // this function returns void
|
||||||
|
@ -545,49 +545,49 @@ bool rPoint(CBotVar* pThis, CBotVar* var, CBotVar* pResult, int& Exception)
|
||||||
|
|
||||||
if ( var == NULL ) return true; // constructor with no parameters is ok
|
if ( var == NULL ) return true; // constructor with no parameters is ok
|
||||||
|
|
||||||
if ( var->GivType() > CBotTypDouble )
|
if ( var->GetType() > CBotTypDouble )
|
||||||
{
|
{
|
||||||
Exception = CBotErrBadNum; return false;
|
Exception = CBotErrBadNum; return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pX = pThis->GivItem("x");
|
pX = pThis->GetItem("x");
|
||||||
if ( pX == NULL )
|
if ( pX == NULL )
|
||||||
{
|
{
|
||||||
Exception = CBotErrUndefItem; return false;
|
Exception = CBotErrUndefItem; return false;
|
||||||
}
|
}
|
||||||
pX->SetValFloat( var->GivValFloat() );
|
pX->SetValFloat( var->GetValFloat() );
|
||||||
var = var->GivNext();
|
var = var->GetNext();
|
||||||
|
|
||||||
if ( var == NULL )
|
if ( var == NULL )
|
||||||
{
|
{
|
||||||
Exception = CBotErrLowParam; return false;
|
Exception = CBotErrLowParam; return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( var->GivType() > CBotTypDouble )
|
if ( var->GetType() > CBotTypDouble )
|
||||||
{
|
{
|
||||||
Exception = CBotErrBadNum; return false;
|
Exception = CBotErrBadNum; return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pY = pThis->GivItem("y");
|
pY = pThis->GetItem("y");
|
||||||
if ( pY == NULL )
|
if ( pY == NULL )
|
||||||
{
|
{
|
||||||
Exception = CBotErrUndefItem; return false;
|
Exception = CBotErrUndefItem; return false;
|
||||||
}
|
}
|
||||||
pY->SetValFloat( var->GivValFloat() );
|
pY->SetValFloat( var->GetValFloat() );
|
||||||
var = var->GivNext();
|
var = var->GetNext();
|
||||||
|
|
||||||
if ( var == NULL )
|
if ( var == NULL )
|
||||||
{
|
{
|
||||||
return true; // ok with only two parameters
|
return true; // ok with only two parameters
|
||||||
}
|
}
|
||||||
|
|
||||||
pZ = pThis->GivItem("z");
|
pZ = pThis->GetItem("z");
|
||||||
if ( pZ == NULL )
|
if ( pZ == NULL )
|
||||||
{
|
{
|
||||||
Exception = CBotErrUndefItem; return false;
|
Exception = CBotErrUndefItem; return false;
|
||||||
}
|
}
|
||||||
pZ->SetValFloat( var->GivValFloat() );
|
pZ->SetValFloat( var->GetValFloat() );
|
||||||
var = var->GivNext();
|
var = var->GetNext();
|
||||||
|
|
||||||
if ( var != NULL )
|
if ( var != NULL )
|
||||||
{
|
{
|
||||||
|
@ -6451,7 +6451,7 @@ bool CRobotMain::IOWriteScene(char *filename, char *filecbot, char *info)
|
||||||
|
|
||||||
version = 1;
|
version = 1;
|
||||||
fWrite(&version, sizeof(long), 1, file); // version of COLOBOT
|
fWrite(&version, sizeof(long), 1, file); // version of COLOBOT
|
||||||
version = CBotProgram::GivVersion();
|
version = CBotProgram::GetVersion();
|
||||||
fWrite(&version, sizeof(long), 1, file); // version of CBOT
|
fWrite(&version, sizeof(long), 1, file); // version of CBOT
|
||||||
|
|
||||||
objRank = 0;
|
objRank = 0;
|
||||||
|
@ -6687,7 +6687,7 @@ CObject* CRobotMain::IOReadScene(char *filename, char *filecbot)
|
||||||
if ( version == 1 )
|
if ( version == 1 )
|
||||||
{
|
{
|
||||||
fRead(&version, sizeof(long), 1, file); // version of CBOT
|
fRead(&version, sizeof(long), 1, file); // version of CBOT
|
||||||
if ( version == CBotProgram::GivVersion() )
|
if ( version == CBotProgram::GetVersion() )
|
||||||
{
|
{
|
||||||
objRank = 0;
|
objRank = 0;
|
||||||
for ( i=0 ; i<1000000 ; i++ )
|
for ( i=0 ; i<1000000 ; i++ )
|
||||||
|
@ -7200,7 +7200,7 @@ void CRobotMain::SetGamerName(char *name)
|
||||||
ReadFreeParam();
|
ReadFreeParam();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gives the player's name.
|
// Getes the player's name.
|
||||||
|
|
||||||
char* CRobotMain::RetGamerName()
|
char* CRobotMain::RetGamerName()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue