2012-03-19 11:44:39 +00:00
|
|
|
|
// * This file is part of the COLOBOT source code
|
2012-03-09 16:08:05 +00:00
|
|
|
|
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
|
|
|
|
|
// *
|
|
|
|
|
// * This program is free software: you can redistribute it and/or modify
|
|
|
|
|
// * it under the terms of the GNU General Public License as published by
|
|
|
|
|
// * the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
// * (at your option) any later version.
|
|
|
|
|
// *
|
|
|
|
|
// * This program is distributed in the hope that it will be useful,
|
|
|
|
|
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// * GNU General Public License for more details.
|
|
|
|
|
// *
|
|
|
|
|
// * You should have received a copy of the GNU General Public License
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// * along with this program. If not, see http://www.gnu.org/licenses/.////////////////////////////////////////////////////////////////////
|
|
|
|
|
// interpr<70>teur pour le language CBot du jeu COLOBOT
|
2012-03-09 16:08:05 +00:00
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// derni<6E>re r<>vision : 03/10/2002 DD
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
#define EXTENDS TRUE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "resource.h"
|
2012-03-19 11:44:39 +00:00
|
|
|
|
#include "CBotDll.h" // d<>finitions publiques
|
2012-03-08 18:32:05 +00:00
|
|
|
|
#include "CBotToken.h" // gestion des tokens
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
#define STACKRUN TRUE // reprise de l'ex<65>cution direct sur une routine suspendue
|
|
|
|
|
#define STACKMEM TRUE // pr<70>r<EFBFBD>serve la m<>moire pour la pile d'ex<65>cution
|
|
|
|
|
#define MAXSTACK 990 // taille du stack r<>serv<72>
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
#define EOX (CBotStack*)-1 // marqueur condition sp<73>ciale
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// r<>sum<75> des classes utilis<69>es, d<>finies ci-apr<70>s
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
class CBotCompExpr; // une expression telle que
|
|
|
|
|
// () <= ()
|
|
|
|
|
class CBotAddExpr; // une expression telle que
|
|
|
|
|
// () + ()
|
2012-03-19 11:44:39 +00:00
|
|
|
|
class CBotParExpr; // un <20>l<EFBFBD>ment de base ou entre parenth<74>se
|
2012-03-08 18:32:05 +00:00
|
|
|
|
// Toto.truc
|
|
|
|
|
// 12.5
|
|
|
|
|
// "chaine"
|
|
|
|
|
// ( expression )
|
|
|
|
|
class CBotExprVar; // un nom de variable tel que
|
|
|
|
|
// Toto
|
|
|
|
|
// chose.truc.machin
|
|
|
|
|
class CBotWhile; // while (...) {...};
|
|
|
|
|
class CBotIf; // if (...) {...} else {...}
|
2012-03-19 11:44:39 +00:00
|
|
|
|
class CBotDefParam; // liste de param<61>tres d'une fonction
|
2012-03-08 18:32:05 +00:00
|
|
|
|
class CBotRepeat; // repeat (nb) {...}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// Gestion de la pile d'ex<65>cution
|
2012-03-08 18:32:05 +00:00
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// en fait, en externe, la seule chose qu'il est possible de faire
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// c'est de cr<63>er une instance d'une pile
|
2012-03-08 18:32:05 +00:00
|
|
|
|
// pour l'utiliser pour la routine CBotProgram::Execute(CBotStack)
|
|
|
|
|
|
|
|
|
|
class CBotStack
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
CBotStack* m_next;
|
|
|
|
|
CBotStack* m_next2;
|
|
|
|
|
CBotStack* m_prev;
|
|
|
|
|
friend class CBotInstArray;
|
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
int m_index;
|
|
|
|
|
#endif
|
|
|
|
|
int m_state;
|
|
|
|
|
int m_step;
|
|
|
|
|
static int m_error;
|
|
|
|
|
static int m_start;
|
|
|
|
|
static int m_end;
|
|
|
|
|
static
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotVar* m_retvar; // r<>sultat d'un return
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotVar* m_var; // r<>sultat des op<6F>rations
|
|
|
|
|
CBotVar* m_listVar; // les variables d<>clar<61>es <20> ce niveau
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
BOOL m_bBlock; // fait partie d'un bloc (variables sont locales <20> ce bloc)
|
2012-03-08 18:32:05 +00:00
|
|
|
|
BOOL m_bOver; // limites de la pile ?
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// BOOL m_bDontDelete; // sp<73>cial, ne pas d<>truire les variables au delete
|
|
|
|
|
CBotProgram* m_prog; // les fonctions d<>finies par user
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
int m_initimer;
|
|
|
|
|
static
|
|
|
|
|
int m_timer;
|
|
|
|
|
static
|
|
|
|
|
CBotString m_labelBreak;
|
|
|
|
|
static
|
|
|
|
|
void* m_pUser;
|
|
|
|
|
|
|
|
|
|
CBotInstr* m_instr; // l'instruction correspondante
|
2012-03-19 11:44:39 +00:00
|
|
|
|
BOOL m_bFunc; // une entr<74>e d'une fonction ?
|
2012-03-08 18:32:05 +00:00
|
|
|
|
CBotCall* m_call; // point de reprise dans un call extern
|
|
|
|
|
friend class CBotTry;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
#if STACKMEM
|
|
|
|
|
static
|
|
|
|
|
CBotStack* FirstStack();
|
|
|
|
|
void Delete();
|
|
|
|
|
#endif
|
|
|
|
|
CBotStack(CBotStack* ppapa);
|
|
|
|
|
~CBotStack();
|
|
|
|
|
BOOL StackOver();
|
|
|
|
|
|
|
|
|
|
int GivError(int& start, int& end);
|
2012-03-19 11:44:39 +00:00
|
|
|
|
int GivError(); // rend le num<75>ro d'erreur retourn<72>
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
void Reset(void* pUser); // plus d'erreur, timer au d<>but
|
|
|
|
|
void SetType(CBotTypResult& type); // d<>termine le type
|
2012-03-08 18:32:05 +00:00
|
|
|
|
int GivType(int mode = 0); // donne le type de valeur sur le stack
|
|
|
|
|
CBotTypResult GivTypResult(int mode = 0); // donne le type complet de valeur sur le stack
|
|
|
|
|
|
|
|
|
|
// void AddVar(CBotVar* p, BOOL bDontDelete=FALSE); // ajoute une variable locale
|
|
|
|
|
void AddVar(CBotVar* p); // ajoute une variable locale
|
|
|
|
|
// void RestoreVar(CBotVar* pVar);
|
|
|
|
|
|
|
|
|
|
CBotVar* FindVar(CBotToken* &p, BOOL bUpdate = FALSE,
|
|
|
|
|
BOOL bModif = FALSE); // trouve une variable
|
|
|
|
|
CBotVar* FindVar(CBotToken& Token, BOOL bUpdate = FALSE,
|
|
|
|
|
BOOL bModif = FALSE);
|
|
|
|
|
CBotVar* FindVar(const char* name);
|
|
|
|
|
CBotVar* FindVar(long ident, BOOL bUpdate = FALSE,
|
|
|
|
|
BOOL bModif = FALSE);
|
|
|
|
|
|
|
|
|
|
CBotVar* CopyVar(CBotToken& Token, BOOL bUpdate = FALSE); // trouve et rend une copie
|
|
|
|
|
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotStack* AddStack(CBotInstr* instr = NULL, BOOL bBlock = FALSE); // <20>tend le stack
|
|
|
|
|
CBotStack* AddStackEOX(CBotCall* instr = NULL, BOOL bBlock = FALSE); // <20>tend le stack
|
2012-03-08 18:32:05 +00:00
|
|
|
|
CBotStack* RestoreStack(CBotInstr* instr = NULL);
|
|
|
|
|
CBotStack* RestoreStackEOX(CBotCall* instr = NULL);
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotStack* AddStack2(BOOL bBlock = FALSE); // <20>tend le stack
|
|
|
|
|
BOOL Return(CBotStack* pFils); // transmet le r<>sultat au dessus
|
|
|
|
|
BOOL ReturnKeep(CBotStack* pFils); // transmet le r<>sultat sans r<>duire la pile
|
2012-03-08 18:32:05 +00:00
|
|
|
|
BOOL BreakReturn(CBotStack* pfils, const char* name = NULL);
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// en cas de break <20>ventuel
|
2012-03-08 18:32:05 +00:00
|
|
|
|
BOOL IfContinue(int state, const char* name);
|
|
|
|
|
// ou de "continue"
|
|
|
|
|
|
|
|
|
|
BOOL IsOk();
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
BOOL SetState(int n, int lim = -10); // s<>lectionne un <20>tat
|
|
|
|
|
int GivState(); // dans quel <20>tat j'<27>re ?
|
|
|
|
|
BOOL IncState(int lim = -10); // passe <20> l'<27>tat suivant
|
|
|
|
|
BOOL IfStep(); // faire du pas <20> pas ?
|
2012-03-08 18:32:05 +00:00
|
|
|
|
BOOL Execute();
|
|
|
|
|
|
|
|
|
|
void SetVar( CBotVar* var );
|
|
|
|
|
void SetCopyVar( CBotVar* var );
|
|
|
|
|
CBotVar* GivVar();
|
|
|
|
|
CBotVar* GivCopyVar();
|
|
|
|
|
CBotVar* GivPtVar();
|
|
|
|
|
BOOL GivRetVar(BOOL bRet);
|
|
|
|
|
long GivVal();
|
|
|
|
|
|
|
|
|
|
void SetStartError(int pos);
|
|
|
|
|
void SetError(int n, CBotToken* token = NULL);
|
|
|
|
|
void SetPosError(CBotToken* token);
|
|
|
|
|
void ResetError(int n, int start, int end);
|
|
|
|
|
void SetBreak(int val, const char* name);
|
|
|
|
|
|
|
|
|
|
void SetBotCall(CBotProgram* p);
|
|
|
|
|
CBotProgram* GivBotCall(BOOL bFirst = FALSE);
|
|
|
|
|
void* GivPUser();
|
|
|
|
|
BOOL GivBlock();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// BOOL ExecuteCall(CBotToken* token, CBotVar** ppVar, CBotTypResult& rettype);
|
|
|
|
|
BOOL ExecuteCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotTypResult& rettype);
|
|
|
|
|
void RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar);
|
|
|
|
|
|
|
|
|
|
BOOL SaveState(FILE* pf);
|
|
|
|
|
BOOL RestoreState(FILE* pf, CBotStack* &pStack);
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
void SetTimer(int n);
|
|
|
|
|
|
|
|
|
|
void GetRunPos(const char* &FunctionName, int &start, int &end);
|
|
|
|
|
CBotVar* GivStackVars(const char* &FunctionName, int level);
|
|
|
|
|
|
|
|
|
|
int m_temp;
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// les routines inline doivent <20>tre d<>clar<61>es dans le fichier .h
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
inline BOOL CBotStack::IsOk()
|
|
|
|
|
{
|
|
|
|
|
return (m_error == 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline int CBotStack::GivState()
|
|
|
|
|
{
|
|
|
|
|
return m_state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline int CBotStack::GivError()
|
|
|
|
|
{
|
|
|
|
|
return m_error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Gestion de la pile de compilation
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CBotCStack
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
CBotCStack* m_next;
|
|
|
|
|
CBotCStack* m_prev;
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
int m_error;
|
|
|
|
|
static
|
|
|
|
|
int m_end;
|
|
|
|
|
int m_start;
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotVar* m_var; // r<>sultat des op<6F>rations
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
BOOL m_bBlock; // fait partie d'un bloc (variables sont locales <20> ce bloc)
|
2012-03-08 18:32:05 +00:00
|
|
|
|
CBotVar* m_listVar;
|
|
|
|
|
|
|
|
|
|
static
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotProgram* m_prog; // liste des fonctions compil<69>es
|
2012-03-08 18:32:05 +00:00
|
|
|
|
static
|
|
|
|
|
CBotTypResult m_retTyp;
|
|
|
|
|
// static
|
|
|
|
|
// CBotToken* m_retClass;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotCStack(CBotCStack* ppapa);
|
|
|
|
|
~CBotCStack();
|
|
|
|
|
|
|
|
|
|
BOOL IsOk();
|
|
|
|
|
int GivError();
|
|
|
|
|
int GivError(int& start, int& end);
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// rend le num<75>ro d'erreur retourn<72>
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
void SetType(CBotTypResult& type);// d<>termine le type
|
2012-03-08 18:32:05 +00:00
|
|
|
|
CBotTypResult GivTypResult(int mode = 0); // donne le type de valeur sur le stack
|
|
|
|
|
int GivType(int mode = 0); // donne le type de valeur sur le stack
|
|
|
|
|
CBotClass* GivClass(); // donne la classe de la valeur sur le stack
|
|
|
|
|
|
|
|
|
|
void AddVar(CBotVar* p); // ajoute une variable locale
|
|
|
|
|
CBotVar* FindVar(CBotToken* &p); // trouve une variable
|
|
|
|
|
CBotVar* FindVar(CBotToken& Token);
|
|
|
|
|
BOOL CheckVarLocal(CBotToken* &pToken);
|
|
|
|
|
CBotVar* CopyVar(CBotToken& Token); // trouve et rend une copie
|
|
|
|
|
|
|
|
|
|
CBotCStack* TokenStack(CBotToken* pToken = NULL, BOOL bBlock = FALSE);
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* Return(CBotInstr* p, CBotCStack* pParent); // transmet le r<>sultat au dessus
|
|
|
|
|
CBotFunction* ReturnFunc(CBotFunction* p, CBotCStack* pParent); // transmet le r<>sultat au dessus
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
void SetVar( CBotVar* var );
|
|
|
|
|
void SetCopyVar( CBotVar* var );
|
|
|
|
|
CBotVar* GivVar();
|
|
|
|
|
|
|
|
|
|
void SetStartError(int pos);
|
|
|
|
|
void SetError(int n, int pos);
|
|
|
|
|
void SetError(int n, CBotToken* p);
|
|
|
|
|
void ResetError(int n, int start, int end);
|
|
|
|
|
|
|
|
|
|
void SetRetType(CBotTypResult& type);
|
|
|
|
|
CBotTypResult GivRetType();
|
|
|
|
|
|
|
|
|
|
// void SetBotCall(CBotFunction* &pFunc);
|
|
|
|
|
void SetBotCall(CBotProgram* p);
|
|
|
|
|
CBotProgram* GivBotCall();
|
|
|
|
|
CBotTypResult CompileCall(CBotToken* &p, CBotVar** ppVars, long& nIdent);
|
|
|
|
|
BOOL CheckCall(CBotToken* &pToken, CBotDefParam* pParam);
|
|
|
|
|
|
|
|
|
|
BOOL NextToken(CBotToken* &p);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern BOOL SaveVar(FILE* pf, CBotVar* pVar);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// classes d<>finissant une instruction
|
2012-03-08 18:32:05 +00:00
|
|
|
|
class CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
static
|
|
|
|
|
CBotStringArray
|
|
|
|
|
m_labelLvl;
|
|
|
|
|
protected:
|
|
|
|
|
CBotToken m_token; // conserve le token
|
|
|
|
|
CBotString name; // debug
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_next; // instructions cha<68>n<EFBFBD>es
|
|
|
|
|
CBotInstr* m_next2b; // seconde liste pour d<>finition en cha<68>ne
|
|
|
|
|
CBotInstr* m_next3; // troisi<73>me liste pour les indices et champs
|
|
|
|
|
CBotInstr* m_next3b; // n<>cessaire pour la d<>claration des tableaux
|
2012-03-08 18:32:05 +00:00
|
|
|
|
/*
|
|
|
|
|
par exemple, le programme suivant
|
|
|
|
|
int x[]; x[1] = 4;
|
|
|
|
|
int y[x[1]][10], z;
|
2012-03-19 11:44:39 +00:00
|
|
|
|
va g<EFBFBD>n<EFBFBD>r<EFBFBD>
|
2012-03-08 18:32:05 +00:00
|
|
|
|
CBotInstrArray
|
|
|
|
|
m_next3b-> CBotEmpty
|
|
|
|
|
m_next->
|
|
|
|
|
CBotExpression ....
|
|
|
|
|
m_next->
|
|
|
|
|
CBotInstrArray
|
|
|
|
|
m_next3b-> CBotExpression ('x') ( m_next3-> CBotIndexExpr ('1') )
|
|
|
|
|
m_next3b-> CBotExpression ('10')
|
|
|
|
|
m_next2-> 'z'
|
|
|
|
|
m_next->...
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
int m_LoopLvl;
|
|
|
|
|
friend class CBotClassInst;
|
|
|
|
|
friend class CBotInt;
|
|
|
|
|
friend class CBotListArray;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotInstr();
|
|
|
|
|
virtual
|
|
|
|
|
~CBotInstr();
|
|
|
|
|
|
|
|
|
|
DllExport//debug
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypResult type, BOOL first = TRUE);
|
|
|
|
|
|
|
|
|
|
virtual
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
virtual
|
|
|
|
|
BOOL Execute(CBotStack* &pj, CBotVar* pVar);
|
|
|
|
|
virtual
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
|
|
|
|
|
virtual
|
|
|
|
|
BOOL ExecuteVar(CBotVar* &pVar, CBotCStack* &pile);
|
|
|
|
|
virtual
|
|
|
|
|
BOOL ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, BOOL bStep, BOOL bExtend);
|
|
|
|
|
virtual
|
|
|
|
|
void RestoreStateVar(CBotStack* &pile, BOOL bMain);
|
|
|
|
|
|
|
|
|
|
virtual
|
|
|
|
|
BOOL CompCase(CBotStack* &pj, int val);
|
|
|
|
|
|
|
|
|
|
void SetToken(CBotToken* p);
|
|
|
|
|
void SetToken(CBotString* name, int start=0, int end=0);
|
|
|
|
|
int GivTokenType();
|
|
|
|
|
CBotToken* GivToken();
|
|
|
|
|
|
|
|
|
|
void AddNext(CBotInstr* n);
|
|
|
|
|
CBotInstr* GivNext();
|
|
|
|
|
void AddNext3(CBotInstr* n);
|
|
|
|
|
CBotInstr* GivNext3();
|
|
|
|
|
void AddNext3b(CBotInstr* n);
|
|
|
|
|
CBotInstr* GivNext3b();
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
void IncLvl(CBotString& label);
|
|
|
|
|
static
|
|
|
|
|
void IncLvl();
|
|
|
|
|
static
|
|
|
|
|
void DecLvl();
|
|
|
|
|
static
|
|
|
|
|
BOOL ChkLvl(CBotString& label, int type);
|
|
|
|
|
|
|
|
|
|
BOOL IsOfClass(CBotString name);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CBotWhile : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
CBotInstr* m_Condition; // la condition
|
|
|
|
|
CBotInstr* m_Block; // les instructions
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotString m_label; // une <20>tiquette s'il y a
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotWhile();
|
|
|
|
|
~CBotWhile();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CBotRepeat : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_NbIter; // le nombre d'it<69>ration
|
2012-03-08 18:32:05 +00:00
|
|
|
|
CBotInstr* m_Block; // les instructions
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotString m_label; // une <20>tiquette s'il y a
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotRepeat();
|
|
|
|
|
~CBotRepeat();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CBotDo : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
CBotInstr* m_Block; // les instructions
|
|
|
|
|
CBotInstr* m_Condition; // la condition
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotString m_label; // une <20>tiquette s'il y a
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotDo();
|
|
|
|
|
~CBotDo();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CBotFor : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
CBotInstr* m_Init; // intruction initiale
|
|
|
|
|
CBotInstr* m_Test; // la condition de test
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_Incr; // instruction pour l'incr<63>ment
|
2012-03-08 18:32:05 +00:00
|
|
|
|
CBotInstr* m_Block; // les instructions
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotString m_label; // une <20>tiquette s'il y a
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotFor();
|
|
|
|
|
~CBotFor();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CBotBreak : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotString m_label; // une <20>tiquette s'il y a
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotBreak();
|
|
|
|
|
~CBotBreak();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CBotReturn : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_Instr; // le param<61>tre <20> retourner
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotReturn();
|
|
|
|
|
~CBotReturn();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CBotSwitch : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_Value; // value <20> chercher
|
2012-03-08 18:32:05 +00:00
|
|
|
|
CBotInstr* m_Block; // les instructions
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotSwitch();
|
|
|
|
|
~CBotSwitch();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CBotCase : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_Value; // valeur <20> comparer
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotCase();
|
|
|
|
|
~CBotCase();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
BOOL CompCase(CBotStack* &pj, int val);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CBotCatch : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
CBotInstr* m_Block; // les instructions
|
|
|
|
|
CBotInstr* m_Cond; // la condition
|
|
|
|
|
CBotCatch* m_next; // le catch suivant
|
|
|
|
|
friend class CBotTry;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotCatch();
|
|
|
|
|
~CBotCatch();
|
|
|
|
|
static
|
|
|
|
|
CBotCatch* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL TestCatch(CBotStack* &pj, int val);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
void RestoreCondState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CBotTry : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
CBotInstr* m_Block; // les instructions
|
|
|
|
|
CBotCatch* m_ListCatch; // les catches
|
|
|
|
|
CBotInstr* m_FinalInst; // instruction finale
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotTry();
|
|
|
|
|
~CBotTry();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CBotThrow : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_Value; // la valeur <20> envoyer
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotThrow();
|
|
|
|
|
~CBotThrow();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CBotStartDebugDD : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotStartDebugDD();
|
|
|
|
|
~CBotStartDebugDD();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CBotIf : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
CBotInstr* m_Condition; // la condition
|
|
|
|
|
CBotInstr* m_Block; // les instructions
|
|
|
|
|
CBotInstr* m_BlockElse; // les instructions
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotIf();
|
|
|
|
|
~CBotIf();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// d<>finition d'un nombre entier
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
class CBotInt : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_var; // la variable <20> initialiser
|
|
|
|
|
CBotInstr* m_expr; // la valeur <20> mettre, s'il y a
|
|
|
|
|
/// CBotInstr* m_next; // plusieurs d<>finitions encha<68>n<EFBFBD>es
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotInt();
|
|
|
|
|
~CBotInt();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, BOOL cont = FALSE, BOOL noskip = FALSE);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// d<>finition d'un tableau
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
class CBotInstArray : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_var; // la variable <20> initialiser
|
2012-03-08 18:32:05 +00:00
|
|
|
|
CBotInstr* m_listass; // liste d'assignations pour le tableau
|
|
|
|
|
CBotTypResult
|
2012-03-19 11:44:39 +00:00
|
|
|
|
m_typevar; // type d'<27>l<EFBFBD>ments
|
2012-03-08 18:32:05 +00:00
|
|
|
|
// CBotString m_ClassName;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotInstArray();
|
|
|
|
|
~CBotInstArray();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResult type);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// d<>finition d'une liste d'assignation pour un tableau
|
2012-03-08 18:32:05 +00:00
|
|
|
|
// int [ ] a [ ] = ( ( 1, 2, 3 ) , ( 3, 2, 1 ) ) ;
|
|
|
|
|
|
|
|
|
|
class CBotListArray : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_expr; // expression pour un <20>l<EFBFBD>ment
|
|
|
|
|
// les autres sont cha<68>n<EFBFBD>s avec CBotInstr::m_next3;
|
2012-03-08 18:32:05 +00:00
|
|
|
|
public:
|
|
|
|
|
CBotListArray();
|
|
|
|
|
~CBotListArray();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResult type);
|
|
|
|
|
BOOL Execute(CBotStack* &pj, CBotVar* pVar);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CBotEmpty : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// d<>finition d'un bool<6F>en
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
class CBotBoolean : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_var; // la variable <20> initialiser
|
|
|
|
|
CBotInstr* m_expr; // la valeur <20> mettre, s'il y a
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotBoolean();
|
|
|
|
|
~CBotBoolean();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, BOOL cont = FALSE, BOOL noskip=FALSE);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// d<>finition d'un nombre r<>el
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
class CBotFloat : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_var; // la variable <20> initialiser
|
|
|
|
|
CBotInstr* m_expr; // la valeur <20> mettre, s'il y a
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotFloat();
|
|
|
|
|
~CBotFloat();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, BOOL cont = FALSE, BOOL noskip=FALSE);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// d<>finition d'un el<65>ment string
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
class CBotIString : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_var; // la variable <20> initialiser
|
|
|
|
|
CBotInstr* m_expr; // la valeur <20> mettre, s'il y a
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotIString();
|
|
|
|
|
~CBotIString();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, BOOL cont = FALSE, BOOL noskip=FALSE);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// d<>finition d'un el<65>ment dans une classe quelconque
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
class CBotClassInst : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_var; // la variable <20> initialiser
|
|
|
|
|
CBotClass* m_pClass; // r<>f<EFBFBD>rence <20> la classe
|
|
|
|
|
CBotInstr* m_Parameters; // les param<61>tres <20> <20>valuer pour le constructeur
|
|
|
|
|
CBotInstr* m_expr; // la valeur <20> mettre, s'il y a
|
|
|
|
|
BOOL m_hasParams; // il y a des param<61>tres ?
|
2012-03-08 18:32:05 +00:00
|
|
|
|
long m_nMethodeIdent;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotClassInst();
|
|
|
|
|
~CBotClassInst();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* pClass = NULL);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CBotCondition : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// left op<6F>rande
|
|
|
|
|
// n'accepte que les expressions pouvant <20>tre <20> gauche d'une assignation
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
class CBotLeftExpr : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
long m_nIdent;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotLeftExpr();
|
|
|
|
|
~CBotLeftExpr();
|
|
|
|
|
static
|
|
|
|
|
CBotLeftExpr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pStack, CBotStack* array);
|
|
|
|
|
|
|
|
|
|
BOOL ExecuteVar(CBotVar* &pVar, CBotCStack* &pile);
|
|
|
|
|
BOOL ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, BOOL bStep);
|
|
|
|
|
void RestoreStateVar(CBotStack* &pile, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// gestion des champs d'une instance
|
|
|
|
|
|
|
|
|
|
class CBotFieldExpr : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
friend class CBotExpression;
|
|
|
|
|
int m_nIdent;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotFieldExpr();
|
|
|
|
|
~CBotFieldExpr();
|
|
|
|
|
void SetUniqNum(int num);
|
|
|
|
|
// static
|
|
|
|
|
// CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL ExecuteVar(CBotVar* &pVar, CBotCStack* &pile);
|
|
|
|
|
BOOL ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, BOOL bStep, BOOL bExtend);
|
|
|
|
|
void RestoreStateVar(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// gestion des index dans les tableaux
|
|
|
|
|
|
|
|
|
|
class CBotIndexExpr : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
CBotInstr* m_expr; // expression pour le calcul de l'index
|
|
|
|
|
friend class CBotLeftExpr;
|
|
|
|
|
friend class CBotExprVar;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotIndexExpr();
|
|
|
|
|
~CBotIndexExpr();
|
|
|
|
|
// static
|
|
|
|
|
// CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL ExecuteVar(CBotVar* &pVar, CBotCStack* &pile);
|
|
|
|
|
BOOL ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, BOOL bStep, BOOL bExtend);
|
|
|
|
|
void RestoreStateVar(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// une expression du genre
|
|
|
|
|
// x = a;
|
|
|
|
|
// x * y + 3;
|
|
|
|
|
|
|
|
|
|
class CBotExpression : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotLeftExpr* m_leftop; // <20>l<EFBFBD>ment de gauche
|
|
|
|
|
CBotInstr* m_rightop; // <20>l<EFBFBD>ment de droite
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotExpression();
|
|
|
|
|
~CBotExpression();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pStack);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CBotListExpression : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_Expr; // la 1<>re expression <20> <20>valuer
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotListExpression();
|
|
|
|
|
~CBotListExpression();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pStack);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CBotLogicExpr : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_condition; // test <20> <20>valuer
|
|
|
|
|
CBotInstr* m_op1; // <20>l<EFBFBD>ment de gauche
|
|
|
|
|
CBotInstr* m_op2; // <20>l<EFBFBD>ment de droite
|
2012-03-08 18:32:05 +00:00
|
|
|
|
friend class CBotTwoOpExpr;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotLogicExpr();
|
|
|
|
|
~CBotLogicExpr();
|
|
|
|
|
// static
|
|
|
|
|
// CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pStack);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CBotBoolExpr : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// une expression <20>ventuellement entre parenth<74>ses ( ... )
|
2012-03-08 18:32:05 +00:00
|
|
|
|
// il n'y a jamais d'instance de cette classe
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// l'objet retourn<72> <20>tant le contenu de la parenth<74>se
|
2012-03-08 18:32:05 +00:00
|
|
|
|
class CBotParExpr : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// expression unaire
|
|
|
|
|
class CBotExprUnaire : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_Expr; // l'expression <20> <20>valuer
|
2012-03-08 18:32:05 +00:00
|
|
|
|
public:
|
|
|
|
|
CBotExprUnaire();
|
|
|
|
|
~CBotExprUnaire();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pStack);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// toutes les op<6F>rations <20> 2 op<6F>randes
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
class CBotTwoOpExpr : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_leftop; // <20>l<EFBFBD>ment de gauche
|
|
|
|
|
CBotInstr* m_rightop; // <20>l<EFBFBD>ment de droite
|
2012-03-08 18:32:05 +00:00
|
|
|
|
public:
|
|
|
|
|
CBotTwoOpExpr();
|
|
|
|
|
~CBotTwoOpExpr();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, int* pOperations = NULL);
|
|
|
|
|
BOOL Execute(CBotStack* &pStack);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// un bloc d'instructions { .... }
|
|
|
|
|
class CBotBlock : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, BOOL bLocal = TRUE);
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* CompileBlkOrInst(CBotToken* &p, CBotCStack* pStack, BOOL bLocal = FALSE);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// le contenu d'un bloc d'instructions ... ; ... ; ... ; ... ;
|
|
|
|
|
class CBotListInstr : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_Instr; // les instructions <20> faire
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotListInstr();
|
|
|
|
|
~CBotListInstr();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, BOOL bLocal = TRUE);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CBotInstrCall : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_Parameters; // les param<61>tres <20> <20>valuer
|
|
|
|
|
// int m_typeRes; // type du r<>sultat
|
|
|
|
|
// CBotString m_RetClassName; // class du r<>sultat
|
2012-03-08 18:32:05 +00:00
|
|
|
|
CBotTypResult
|
2012-03-19 11:44:39 +00:00
|
|
|
|
m_typRes; // type complet du r<>sultat
|
2012-03-08 18:32:05 +00:00
|
|
|
|
long m_nFuncIdent; // id de la fonction
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotInstrCall();
|
|
|
|
|
~CBotInstrCall();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// un appel d'une m<>thode
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
class CBotInstrMethode : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_Parameters; // les param<61>tres <20> <20>valuer
|
|
|
|
|
// int m_typeRes; // type du r<>sultat
|
|
|
|
|
// CBotString m_RetClassName; // class du r<>sultat
|
2012-03-08 18:32:05 +00:00
|
|
|
|
CBotTypResult
|
2012-03-19 11:44:39 +00:00
|
|
|
|
m_typRes; // type complet du r<>sultat
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotString m_NomMethod; // nom de la m<>thode
|
|
|
|
|
long m_MethodeIdent; // identificateur de la m<>thode
|
2012-03-08 18:32:05 +00:00
|
|
|
|
// long m_nThisIdent; // identificateur pour "this"
|
|
|
|
|
CBotString m_ClassName; // nom de la classe
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotInstrMethode();
|
|
|
|
|
~CBotInstrMethode();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotVar* pVar);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
BOOL ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToken, BOOL bStep, BOOL bExtend);
|
|
|
|
|
void RestoreStateVar(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// expression donnant un nom de variable
|
|
|
|
|
|
|
|
|
|
class CBotExprVar : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
long m_nIdent;
|
|
|
|
|
friend class CBotPostIncExpr;
|
|
|
|
|
friend class CBotPreIncExpr;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotExprVar();
|
|
|
|
|
~CBotExprVar();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, int privat=PR_PROTECT);
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* CompileMethode(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
BOOL ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, BOOL bStep);
|
|
|
|
|
BOOL Execute2Var(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToken, BOOL bStep);
|
|
|
|
|
void RestoreStateVar(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CBotPostIncExpr : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
CBotInstr* m_Instr;
|
|
|
|
|
friend class CBotParExpr;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotPostIncExpr();
|
|
|
|
|
~CBotPostIncExpr();
|
|
|
|
|
// static
|
|
|
|
|
// CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CBotPreIncExpr : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
CBotInstr* m_Instr;
|
|
|
|
|
friend class CBotParExpr;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotPreIncExpr();
|
|
|
|
|
~CBotPreIncExpr();
|
|
|
|
|
// static
|
|
|
|
|
// CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CBotLeftExprVar : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
public:
|
|
|
|
|
CBotTypResult
|
2012-03-19 11:44:39 +00:00
|
|
|
|
m_typevar; // type de variable d<>clar<61>e
|
2012-03-08 18:32:05 +00:00
|
|
|
|
long m_nIdent; // identificateur unique pour cette variable
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotLeftExprVar();
|
|
|
|
|
~CBotLeftExprVar();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CBotExprBool : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotExprBool();
|
|
|
|
|
~CBotExprBool();
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CBotExprNull : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotExprNull();
|
|
|
|
|
~CBotExprNull();
|
|
|
|
|
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CBotExprNan : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotExprNan();
|
|
|
|
|
~CBotExprNan();
|
|
|
|
|
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CBotNew : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotInstr* m_Parameters; // les param<61>tres <20> <20>valuer
|
2012-03-08 18:32:05 +00:00
|
|
|
|
long m_nMethodeIdent;
|
|
|
|
|
// long m_nThisIdent;
|
|
|
|
|
CBotToken m_vartoken;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotNew();
|
|
|
|
|
~CBotNew();
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// expression repr<70>sentant un nombre
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
class CBotExprNum : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
int m_numtype; // et le type de nombre
|
|
|
|
|
long m_valint; // valeur pour un int
|
|
|
|
|
float m_valfloat; // valeur pour un float
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotExprNum();
|
|
|
|
|
~CBotExprNum();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// expression repr<70>sentant une chaine de caract<63>res
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
class CBotExprAlpha : public CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotExprAlpha();
|
|
|
|
|
~CBotExprAlpha();
|
|
|
|
|
static
|
|
|
|
|
CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define MAX(a,b) ((a>b) ? a : b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// classe pour la gestion des nombres entier (int)
|
|
|
|
|
class CBotVarInt : public CBotVar
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
int m_val; // la valeur
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotString m_defnum; // le nom si donn<6E> par DefineNum
|
2012-03-08 18:32:05 +00:00
|
|
|
|
friend class CBotVar;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotVarInt( const CBotToken* name );
|
|
|
|
|
// ~CBotVarInt();
|
|
|
|
|
|
|
|
|
|
void SetValInt(int val, const char* s = NULL);
|
|
|
|
|
void SetValFloat(float val);
|
|
|
|
|
int GivValInt();
|
|
|
|
|
float GivValFloat();
|
|
|
|
|
CBotString GivValString();
|
|
|
|
|
|
|
|
|
|
void Copy(CBotVar* pSrc, BOOL bName=TRUE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Add(CBotVar* left, CBotVar* right); // addition
|
|
|
|
|
void Sub(CBotVar* left, CBotVar* right); // soustraction
|
|
|
|
|
void Mul(CBotVar* left, CBotVar* right); // multiplication
|
|
|
|
|
int Div(CBotVar* left, CBotVar* right); // division
|
|
|
|
|
int Modulo(CBotVar* left, CBotVar* right); // reste de division
|
|
|
|
|
void Power(CBotVar* left, CBotVar* right); // puissance
|
|
|
|
|
|
|
|
|
|
BOOL Lo(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Hi(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Ls(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Hs(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Eq(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Ne(CBotVar* left, CBotVar* right);
|
|
|
|
|
|
|
|
|
|
void XOr(CBotVar* left, CBotVar* right);
|
|
|
|
|
void Or(CBotVar* left, CBotVar* right);
|
|
|
|
|
void And(CBotVar* left, CBotVar* right);
|
|
|
|
|
|
|
|
|
|
void SL(CBotVar* left, CBotVar* right);
|
|
|
|
|
void SR(CBotVar* left, CBotVar* right);
|
|
|
|
|
void ASR(CBotVar* left, CBotVar* right);
|
|
|
|
|
|
|
|
|
|
void Neg();
|
|
|
|
|
void Not();
|
|
|
|
|
void Inc();
|
|
|
|
|
void Dec();
|
|
|
|
|
|
|
|
|
|
BOOL Save0State(FILE* pf);
|
|
|
|
|
BOOL Save1State(FILE* pf);
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// classe pour la gestion des nombres r<>els (float)
|
2012-03-08 18:32:05 +00:00
|
|
|
|
class CBotVarFloat : CBotVar
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
float m_val; // la valeur
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotVarFloat( const CBotToken* name );
|
|
|
|
|
// ~CBotVarFloat();
|
|
|
|
|
|
|
|
|
|
void SetValInt(int val, const char* s = NULL);
|
|
|
|
|
void SetValFloat(float val);
|
|
|
|
|
int GivValInt();
|
|
|
|
|
float GivValFloat();
|
|
|
|
|
CBotString GivValString();
|
|
|
|
|
|
|
|
|
|
void Copy(CBotVar* pSrc, BOOL bName=TRUE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Add(CBotVar* left, CBotVar* right); // addition
|
|
|
|
|
void Sub(CBotVar* left, CBotVar* right); // soustraction
|
|
|
|
|
void Mul(CBotVar* left, CBotVar* right); // multiplication
|
|
|
|
|
int Div(CBotVar* left, CBotVar* right); // division
|
|
|
|
|
int Modulo(CBotVar* left, CBotVar* right); // reste de division
|
|
|
|
|
void Power(CBotVar* left, CBotVar* right); // puissance
|
|
|
|
|
|
|
|
|
|
BOOL Lo(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Hi(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Ls(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Hs(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Eq(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Ne(CBotVar* left, CBotVar* right);
|
|
|
|
|
|
|
|
|
|
void Neg();
|
|
|
|
|
void Inc();
|
|
|
|
|
void Dec();
|
|
|
|
|
|
|
|
|
|
BOOL Save1State(FILE* pf);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// classe pour la gestion des cha<68>nes (String)
|
2012-03-08 18:32:05 +00:00
|
|
|
|
class CBotVarString : CBotVar
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
CBotString m_val; // la valeur
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotVarString( const CBotToken* name );
|
|
|
|
|
// ~CBotVarString();
|
|
|
|
|
|
|
|
|
|
void SetValString(const char* p);
|
|
|
|
|
CBotString GivValString();
|
|
|
|
|
|
|
|
|
|
void Copy(CBotVar* pSrc, BOOL bName=TRUE);
|
|
|
|
|
|
|
|
|
|
void Add(CBotVar* left, CBotVar* right); // addition
|
|
|
|
|
|
|
|
|
|
BOOL Lo(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Hi(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Ls(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Hs(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Eq(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Ne(CBotVar* left, CBotVar* right);
|
|
|
|
|
|
|
|
|
|
BOOL Save1State(FILE* pf);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// classe pour la gestion des boolean
|
|
|
|
|
class CBotVarBoolean : CBotVar
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
BOOL m_val; // la valeur
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotVarBoolean( const CBotToken* name );
|
|
|
|
|
// ~CBotVarBoolean();
|
|
|
|
|
|
|
|
|
|
void SetValInt(int val, const char* s = NULL);
|
|
|
|
|
void SetValFloat(float val);
|
|
|
|
|
int GivValInt();
|
|
|
|
|
float GivValFloat();
|
|
|
|
|
CBotString GivValString();
|
|
|
|
|
|
|
|
|
|
void Copy(CBotVar* pSrc, BOOL bName=TRUE);
|
|
|
|
|
|
|
|
|
|
void And(CBotVar* left, CBotVar* right);
|
|
|
|
|
void Or(CBotVar* left, CBotVar* right);
|
|
|
|
|
void XOr(CBotVar* left, CBotVar* right);
|
|
|
|
|
void Not();
|
|
|
|
|
BOOL Eq(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Ne(CBotVar* left, CBotVar* right);
|
|
|
|
|
|
|
|
|
|
BOOL Save1State(FILE* pf);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// classe pour la gestion des instances de classe
|
|
|
|
|
class CBotVarClass : public CBotVar
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
static
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotVarClass* m_ExClass; // liste des instances existantes <20> un moment donn<6E>
|
|
|
|
|
CBotVarClass* m_ExNext; // pour cette liste g<>n<EFBFBD>rale
|
|
|
|
|
CBotVarClass* m_ExPrev; // pour cette liste g<>n<EFBFBD>rale
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotClass* m_pClass; // la d<>finition de la classe
|
2012-03-08 18:32:05 +00:00
|
|
|
|
CBotVarClass* m_pParent; // l'instance dans la classe parent
|
|
|
|
|
CBotVar* m_pVar; // contenu
|
|
|
|
|
friend class CBotVar; // mon papa est un copain
|
|
|
|
|
friend class CBotVarPointer; // et le pointeur aussi
|
|
|
|
|
int m_CptUse; // compteur d'utilisation
|
|
|
|
|
long m_ItemIdent; // identificateur (unique) de l'instance
|
2012-03-19 11:44:39 +00:00
|
|
|
|
BOOL m_bConstructor; // set si un constructeur a <20>t<EFBFBD> appel<65>
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotVarClass( const CBotToken* name, CBotTypResult& type );
|
|
|
|
|
// CBotVarClass( const CBotToken* name, CBotTypResult& type, int &nIdent );
|
|
|
|
|
~CBotVarClass();
|
|
|
|
|
// void InitCBotVarClass( const CBotToken* name, CBotTypResult& type, int &nIdent );
|
|
|
|
|
|
|
|
|
|
void Copy(CBotVar* pSrc, BOOL bName=TRUE);
|
|
|
|
|
void SetClass(CBotClass* pClass); //, int &nIdent);
|
|
|
|
|
CBotClass* GivClass();
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotVar* GivItem(const char* name); // rend un <20>l<EFBFBD>ment d'une classe selon son nom (*)
|
2012-03-08 18:32:05 +00:00
|
|
|
|
CBotVar* GivItemRef(int nIdent);
|
|
|
|
|
|
|
|
|
|
CBotVar* GivItem(int n, BOOL bExtend);
|
|
|
|
|
CBotVar* GivItemList();
|
|
|
|
|
|
|
|
|
|
CBotString GivValString();
|
|
|
|
|
|
|
|
|
|
BOOL Save1State(FILE* pf);
|
|
|
|
|
void Maj(void* pUser, BOOL bContinue);
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
void IncrementUse(); // une r<>f<EFBFBD>rence en plus
|
|
|
|
|
void DecrementUse(); // une r<>f<EFBFBD>rence en moins
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
CBotVarClass*
|
|
|
|
|
GivPointer();
|
|
|
|
|
void SetItemList(CBotVar* pVar);
|
|
|
|
|
|
|
|
|
|
void SetIdent(long n);
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
CBotVarClass*
|
|
|
|
|
CBotVarClass::Find(long id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CBotVar* GivMyThis();
|
|
|
|
|
|
|
|
|
|
BOOL Eq(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Ne(CBotVar* left, CBotVar* right);
|
|
|
|
|
|
|
|
|
|
void ConstructorSet();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// classe pour la gestion des pointeurs <20> une instances de classe
|
2012-03-08 18:32:05 +00:00
|
|
|
|
class CBotVarPointer : public CBotVar
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
CBotVarClass*
|
|
|
|
|
m_pVarClass; // contenu
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotClass* m_pClass; // la classe pr<70>vue pour ce pointeur
|
2012-03-08 18:32:05 +00:00
|
|
|
|
friend class CBotVar; // mon papa est un copain
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotVarPointer( const CBotToken* name, CBotTypResult& type );
|
|
|
|
|
~CBotVarPointer();
|
|
|
|
|
|
|
|
|
|
void Copy(CBotVar* pSrc, BOOL bName=TRUE);
|
|
|
|
|
void SetClass(CBotClass* pClass);
|
|
|
|
|
CBotClass* GivClass();
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotVar* GivItem(const char* name); // rend un <20>l<EFBFBD>ment d'une classe selon son nom (*)
|
2012-03-08 18:32:05 +00:00
|
|
|
|
CBotVar* GivItemRef(int nIdent);
|
|
|
|
|
CBotVar* GivItemList();
|
|
|
|
|
|
|
|
|
|
CBotString GivValString();
|
|
|
|
|
void SetPointer(CBotVar* p);
|
|
|
|
|
CBotVarClass*
|
|
|
|
|
GivPointer();
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
void SetIdent(long n); // associe un num<75>ro d'identification (unique)
|
|
|
|
|
long GivIdent(); // donne le num<75>ro d'identification associ<63>
|
2012-03-08 18:32:05 +00:00
|
|
|
|
void ConstructorSet();
|
|
|
|
|
|
|
|
|
|
BOOL Save1State(FILE* pf);
|
|
|
|
|
void Maj(void* pUser, BOOL bContinue);
|
|
|
|
|
|
|
|
|
|
BOOL Eq(CBotVar* left, CBotVar* right);
|
|
|
|
|
BOOL Ne(CBotVar* left, CBotVar* right);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// classe pour les tableaux
|
|
|
|
|
|
|
|
|
|
#define MAXARRAYSIZE 9999
|
|
|
|
|
|
|
|
|
|
class CBotVarArray : public CBotVar
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
CBotVarClass*
|
2012-03-19 11:44:39 +00:00
|
|
|
|
m_pInstance; // instance g<>rant le tableau
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
friend class CBotVar; // papa est un copain
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotVarArray( const CBotToken* name, CBotTypResult& type );
|
|
|
|
|
~CBotVarArray();
|
|
|
|
|
|
|
|
|
|
void SetPointer(CBotVar* p);
|
|
|
|
|
CBotVarClass*
|
|
|
|
|
GivPointer();
|
|
|
|
|
|
|
|
|
|
void Copy(CBotVar* pSrc, BOOL bName=TRUE);
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotVar* GivItem(int n, BOOL bGrow=FALSE); // rend un <20>l<EFBFBD>ment selon son index num<75>rique
|
|
|
|
|
// agrandi le tableau si n<>cessaire si bExtend
|
|
|
|
|
// CBotVar* GivItem(const char* name); // rend un <20>l<EFBFBD>ment selon son index lit<69>ral
|
|
|
|
|
CBotVar* GivItemList(); // donne le premier <20>l<EFBFBD>ment de la liste
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotString GivValString(); // donne le contenu du tableau dans une cha<68>ne
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
BOOL Save1State(FILE* pf);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern CBotInstr* CompileParams(CBotToken* &p, CBotCStack* pStack, CBotVar** ppVars);
|
|
|
|
|
|
|
|
|
|
extern BOOL TypeCompatible( CBotTypResult& type1, CBotTypResult& type2, int op = 0 );
|
|
|
|
|
extern BOOL TypesCompatibles( CBotTypResult& type1, CBotTypResult& type2 );
|
|
|
|
|
|
|
|
|
|
extern BOOL WriteWord(FILE* pf, WORD w);
|
|
|
|
|
extern BOOL ReadWord(FILE* pf, WORD& w);
|
|
|
|
|
extern BOOL ReadLong(FILE* pf, long& w);
|
|
|
|
|
extern BOOL WriteFloat(FILE* pf, float w);
|
|
|
|
|
extern BOOL WriteLong(FILE* pf, long w);
|
|
|
|
|
extern BOOL ReadFloat(FILE* pf, float& w);
|
|
|
|
|
extern BOOL WriteString(FILE* pf, CBotString s);
|
|
|
|
|
extern BOOL ReadString(FILE* pf, CBotString& s);
|
|
|
|
|
extern BOOL WriteType(FILE* pf, CBotTypResult type);
|
|
|
|
|
extern BOOL ReadType(FILE* pf, CBotTypResult& type);
|
|
|
|
|
|
|
|
|
|
extern float GivNumFloat( const char* p );
|
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
extern void DEBUG( const char* text, int val, CBotStack* pile );
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////
|
|
|
|
|
// classe pour les appels de routines (externes)
|
|
|
|
|
|
|
|
|
|
class CBotCall
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
static
|
|
|
|
|
CBotCall* m_ListCalls;
|
|
|
|
|
static
|
|
|
|
|
void* m_pUser;
|
|
|
|
|
long m_nFuncIdent;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
CBotString m_name;
|
|
|
|
|
BOOL (*m_rExec) (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser) ;
|
|
|
|
|
CBotTypResult
|
|
|
|
|
(*m_rComp) (CBotVar* &pVar, void* pUser) ;
|
|
|
|
|
CBotCall* m_next;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotCall(const char* name,
|
|
|
|
|
BOOL rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
|
|
|
|
CBotTypResult rCompile (CBotVar* &pVar, void* pUser));
|
|
|
|
|
~CBotCall();
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
BOOL AddFunction(const char* name,
|
|
|
|
|
BOOL rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
|
|
|
|
CBotTypResult rCompile (CBotVar* &pVar, void* pUser));
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
CBotTypResult
|
|
|
|
|
CompileCall(CBotToken* &p, CBotVar** ppVars, CBotCStack* pStack, long& nIdent);
|
|
|
|
|
static
|
|
|
|
|
BOOL CheckCall(const char* name);
|
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
|
// int DoCall(CBotToken* &p, CBotVar** ppVars, CBotStack* pStack, CBotTypResult& rettype);
|
|
|
|
|
static
|
|
|
|
|
int DoCall(long& nIdent, CBotToken* token, CBotVar** ppVars, CBotStack* pStack, CBotTypResult& rettype);
|
|
|
|
|
#if STACKRUN
|
|
|
|
|
BOOL Run(CBotStack* pStack);
|
|
|
|
|
static
|
|
|
|
|
BOOL RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotStack* pStack);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
CBotString GivName();
|
|
|
|
|
CBotCall* Next();
|
|
|
|
|
|
|
|
|
|
static void SetPUser(void* pUser);
|
|
|
|
|
static void Free();
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// classe g<>rant les m<>thodes d<>clar<61>es par AddFunction sur une classe
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
class CBotCallMethode
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
CBotString m_name;
|
|
|
|
|
BOOL (*m_rExec) (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception);
|
|
|
|
|
CBotTypResult
|
|
|
|
|
(*m_rComp) (CBotVar* pThis, CBotVar* &pVar);
|
|
|
|
|
CBotCallMethode* m_next;
|
|
|
|
|
friend class CBotClass;
|
|
|
|
|
long m_nFuncIdent;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotCallMethode(const char* name,
|
|
|
|
|
BOOL rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception),
|
|
|
|
|
CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar));
|
|
|
|
|
~CBotCallMethode();
|
|
|
|
|
|
|
|
|
|
CBotTypResult
|
|
|
|
|
CompileCall(const char* name, CBotVar* pThis,
|
|
|
|
|
CBotVar** ppVars, CBotCStack* pStack,
|
|
|
|
|
long& nIdent);
|
|
|
|
|
|
|
|
|
|
int DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotVar* &pResult, CBotStack* pStack, CBotToken* pFunc);
|
|
|
|
|
|
|
|
|
|
CBotString GivName();
|
|
|
|
|
CBotCallMethode* Next();
|
|
|
|
|
void AddNext(CBotCallMethode* p);
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// une liste de param<61>tres
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
class CBotDefParam
|
|
|
|
|
{
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotToken m_token; // nom du param<61>tre
|
2012-03-08 18:32:05 +00:00
|
|
|
|
CBotString m_typename; // nom du type
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotTypResult m_type; // type de param<61>tre
|
|
|
|
|
CBotDefParam* m_next; // param<61>tre suivant
|
2012-03-08 18:32:05 +00:00
|
|
|
|
long m_nIdent;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CBotDefParam();
|
|
|
|
|
~CBotDefParam();
|
|
|
|
|
static
|
|
|
|
|
CBotDefParam* Compile(CBotToken* &p, CBotCStack* pStack);
|
|
|
|
|
BOOL Execute(CBotVar** ppVars, CBotStack* &pj);
|
|
|
|
|
void RestoreState(CBotStack* &pj, BOOL bMain);
|
|
|
|
|
|
|
|
|
|
void AddNext(CBotDefParam* p);
|
|
|
|
|
int GivType();
|
|
|
|
|
CBotTypResult GivTypResult();
|
|
|
|
|
CBotDefParam* GivNext();
|
|
|
|
|
|
|
|
|
|
CBotString GivParamString();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2012-03-19 11:44:39 +00:00
|
|
|
|
// une d<>claration de fonction
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
class CBotFunction : CBotInstr
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
// gestion d'une liste (static) de fonctions publiques
|
|
|
|
|
static
|
|
|
|
|
CBotFunction* m_listPublic;
|
|
|
|
|
CBotFunction* m_nextpublic;
|
|
|
|
|
CBotFunction* m_prevpublic;
|
|
|
|
|
friend class CBotCStack;
|
|
|
|
|
// long m_nThisIdent;
|
|
|
|
|
long m_nFuncIdent;
|
2012-03-19 11:44:39 +00:00
|
|
|
|
BOOL m_bSynchro; // m<>thode synchronis<69>e ?
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
private:
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotDefParam* m_Param; // liste des param<61>tres
|
2012-03-08 18:32:05 +00:00
|
|
|
|
CBotInstr* m_Block; // le bloc d'instructions
|
|
|
|
|
CBotFunction* m_next;
|
|
|
|
|
CBotToken m_retToken; // si retourne un CBotTypClass
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotTypResult m_retTyp; // type complet du r<>sultat
|
2012-03-08 18:32:05 +00:00
|
|
|
|
|
|
|
|
|
BOOL m_bPublic; // fonction publique
|
|
|
|
|
BOOL m_bExtern; // fonction extern
|
2012-03-19 11:44:39 +00:00
|
|
|
|
CBotString m_MasterClass; // nom de la classe qu'on d<>rive
|
2012-03-08 18:32:05 +00:00
|
|
|
|
CBotProgram* m_pProg;
|
|
|
|
|
friend class CBotProgram;
|
|
|
|
|
friend class CBotClass;
|
|
|
|
|
|
|
|
|
|
CBotToken m_extern; // pour la position du mot "extern"
|
|
|
|
|
CBotToken m_openpar;
|
|
|
|
|
CBotToken m_closepar;
|
|
|
|
|
CBotToken m_openblk;
|
|
|
|
|
CBotToken m_closeblk;
|
|
|
|
|
public:
|
|
|
|
|
CBotFunction::CBotFunction();
|
|
|
|
|
CBotFunction::~CBotFunction();
|
|
|
|
|
static
|
|
|
|
|
CBotFunction* Compile(CBotToken* &p, CBotCStack* pStack, CBotFunction* pFunc, BOOL bLocal = TRUE);
|
|
|
|
|
static
|
|
|
|
|
CBotFunction* Compile1(CBotToken* &p, CBotCStack* pStack, CBotClass* pClass);
|
|
|
|
|
BOOL Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance = NULL);
|
|
|
|
|
void RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance = NULL);
|
|
|
|
|
|
|
|
|
|
void AddNext(CBotFunction* p);
|
|
|
|
|
CBotTypResult CompileCall(const char* name, CBotVar** ppVars, long& nIdent);
|
|
|
|
|
CBotFunction* FindLocalOrPublic(long& nIdent, const char* name, CBotVar** ppVars, CBotTypResult& TypeOrError, BOOL bPublic = TRUE);
|
|
|
|
|
|
|
|
|
|
int DoCall(long& nIdent, const char* name, CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken);
|
|
|
|
|
void RestoreCall(long& nIdent, const char* name, CBotVar** ppVars, CBotStack* pStack);
|
|
|
|
|
int DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken, CBotClass* pClass);
|
|
|
|
|
void RestoreCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotStack* pStack, CBotClass* pClass);
|
|
|
|
|
BOOL CheckParam(CBotDefParam* pParam);
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
void AddPublic(CBotFunction* pfunc);
|
|
|
|
|
|
|
|
|
|
CBotString GivName();
|
|
|
|
|
CBotString GivParams();
|
|
|
|
|
BOOL IsPublic();
|
|
|
|
|
BOOL IsExtern();
|
|
|
|
|
CBotFunction* Next();
|
|
|
|
|
|
|
|
|
|
BOOL GetPosition(int& start, int& stop, CBotGet modestart, CBotGet modestop);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|