Merge branch 'dev' into dev-opengl

Pulled changes & resolved conflicts
dev-ui
Piotr Dziwinski 2012-07-27 18:09:50 +02:00
commit ab8e55a651
26 changed files with 7486 additions and 7835 deletions

View File

@ -16,8 +16,8 @@ find_package(PNG REQUIRED)
set(CMAKE_BUILD_TYPE debug) set(CMAKE_BUILD_TYPE debug)
# Global compile flags # Global compile flags
set(CMAKE_CXX_FLAGS_RELEASE "-O2") set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall -std=gnu++0x")
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -O0") set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -std=gnu++0x")
# Subdirectory with sources # Subdirectory with sources
add_subdirectory(src bin) add_subdirectory(src bin)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,279 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// French (France) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
#ifdef _WIN32
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
ID_IF "if"
ID_ELSE "else"
ID_WHILE "while"
ID_DO "do"
ID_FOR "for"
ID_BREAK "break"
ID_CONTINUE "continue"
ID_SWITCH "switch"
ID_CASE "case"
ID_DEFAULT "default"
ID_TRY "try"
ID_THROW "throw"
ID_CATCH "catch"
ID_FINALLY "finally"
ID_TXT_AND "and"
ID_TXT_OR "or"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_DEBUGDD "STARTDEBUGDD"
ID_INT "int"
ID_FLOAT "float"
ID_BOOLEAN "boolean"
ID_STRING "string"
ID_VOID "void"
ID_BOOL "bool"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_TXT_NOT "not"
ID_RETURN "return"
ID_CLASS "class"
ID_EXTENDS "extends"
ID_SYNCHO "synchronized"
ID_NEW "new"
ID_PUBLIC "public"
ID_EXTERN "extern"
ID_FINAL "final"
ID_STATIC "static"
ID_PROTECTED "protected"
ID_PRIVATE "private"
ID_REPEAT "repeat"
END
STRINGTABLE DISCARDABLE
BEGIN
TX_OPENPAR "Il manque une parenthèse ouvrante."
TX_CLOSEPAR "Il manque une parenthèse fermante."
TX_NOTBOOL "L'expression doit être un boolean."
TX_UNDEFVAR "Variable non déclarée."
TX_BADLEFT "Assignation impossible."
TX_ENDOF "Terminateur point-virgule non trouvé."
TX_OUTCASE "Instruction ""case"" hors d'un bloc ""switch""."
TX_NOTERM "Instructions après la fin."
END
STRINGTABLE DISCARDABLE
BEGIN
TX_CLOSEBLK "Il manque la fin du bloc."
TX_ELSEWITHOUTIF "Instruction ""else"" sans ""if"" correspondant."
TX_OPENBLK "Début d'un bloc attendu."
TX_BADTYPE "Mauvais type de résultat pour l'assignation."
TX_REDEFVAR "Redéfinition d'une variable."
TX_BAD2TYPE "Les deux opérandes ne sont pas de types compatibles."
TX_UNDEFCALL "Routine inconnue."
TX_MISDOTS "Séparateur "" : "" attendu."
TX_WHILE "Manque le mot ""while""."
TX_BREAK "Instruction ""break"" en dehors d'une boucle."
TX_LABEL "Un label ne peut se placer que devant un ""for"", un ""while"" ou un ""do""."
TX_NOLABEL "Cette étiquette n'existe pas"
TX_NOCASE "Manque une instruction ""case""."
TX_BADNUM "Un nombre est attendu."
TX_VOID "Paramètre void."
TX_NOTYP "Déclaration de type attendu."
END
STRINGTABLE DISCARDABLE
BEGIN
TX_DIVZERO "Division par zéro."
TX_NOTINIT "Variable non initialisée."
TX_BADTHROW "Valeur négative refusée pour ""throw""."
TX_NORETVAL "La fonction n'a pas retourné de résultat"
TX_NORUN "Pas de fonction en exécution"
TX_NOCALL "Appel d'une fonction inexistante"
TX_NOCLASS "Cette classe n'existe pas"
TX_NULLPT "Pointeur nul."
TX_OPNAN "Opération sur un ""nan"""
TX_OUTARRAY "Accès hors du tableau"
TX_STACKOVER "Dépassement de la pile"
TX_DELETEDPT "Pointeur à un objet détruit"
TX_FILEOPEN "Ouverture du fichier impossible"
TX_NOTOPEN "Fichier pas ouvert"
TX_ERRREAD "Erreur de lecture"
TX_ERRWRITE "Erreur d'écriture"
END
STRINGTABLE DISCARDABLE
BEGIN
TX_NOVAR "Nom d'une variable attendu."
TX_NOFONC "Nom de la fonction attendu."
TX_OVERPARAM "Trop de paramètres."
TX_REDEF "Cette fonction existe déjà."
TX_LOWPARAM "Pas assez de paramètres."
TX_BADPARAM "Aucune fonction de ce nom n'accepte ce(s) type(s) de paramètre(s)."
TX_NUMPARAM "Aucune fonction de ce nom n'accepte ce nombre de paramètres."
TX_NOITEM "Cet élément n'existe pas dans cette classe."
TX_DOT "L'objet n'est pas une instance d'une classe."
TX_NOCONST "Il n'y a pas de constructeur approprié."
TX_REDEFCLASS "Cette classe existe déjà."
TX_CLBRK """ ] "" attendu."
TX_RESERVED "Ce mot est réservé."
TX_BADNEW "Mauvais argument pour ""new""."
TX_OPBRK """ [ "" attendu."
TX_BADSTRING "Une chaîne de caractère est attendue."
END
STRINGTABLE DISCARDABLE
BEGIN
TX_BADINDEX "Mauvais type d'index"
TX_PRIVATE "Membre privé de la classe"
TX_NOPUBLIC """public"" manque"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_OPENPAR "("
ID_CLOSEPAR ")"
ID_OPBLK "{"
ID_CLBLK "}"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_SEP ";"
ID_COMMA ","
ID_DOTS ":"
ID_DOT "."
ID_OPBRK "["
ID_CLBRK "]"
ID_DBLDOTS "::"
ID_LOGIC "?"
ID_ADD "+"
ID_SUB "-"
ID_MUL "*"
ID_DIV "/"
ID_ASS "="
ID_ASSADD "+="
ID_ASSSUB "-="
ID_ASSMUL "*="
END
STRINGTABLE DISCARDABLE
BEGIN
ID_TRUE "true"
ID_FALSE "false"
ID_NULL "null"
ID_NAN "nan"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_ASSDIV "/="
ID_ASSOR "|="
ID_ASSAND "&="
ID_ASSXOR "^="
ID_ASSSL "<<="
ID_ASSSR ">>>="
ID_ASSASR ">>="
ID_SL "<<"
ID_SR ">>>"
ID_ASR ">>"
ID_INC "++"
ID_DEC "--"
ID_LO "<"
ID_HI ">"
ID_LS "<="
ID_HS ">="
END
STRINGTABLE DISCARDABLE
BEGIN
ID_EQ "=="
ID_NE "!="
ID_AND "&"
ID_XOR "^"
ID_OR "|"
ID_LOG_AND "&&"
ID_LOG_OR "||"
ID_LOG_NOT "!"
ID_NOT "~"
ID_MODULO "%"
ID_POWER "**"
ID_ASSMODULO "%="
END
STRINGTABLE DISCARDABLE
BEGIN
TX_UNDEF "undefined"
TX_NAN "not a number"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_SUPER "super"
END
#endif // French (France) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -93,7 +93,7 @@ CBotInstr* CBotAddExpr::Compile(CBotToken* &p, CBotStack* pStack)
// fait l'opération d'addition ou de soustraction // fait l'opération d'addition ou de soustraction
BOOL CBotAddExpr::Execute(CBotStack* &pStack) bool CBotAddExpr::Execute(CBotStack* &pStack)
{ {
CBotStack* pStk1 = pStack->AddStack(this); // ajoute un élément à la pile CBotStack* pStk1 = pStack->AddStack(this); // ajoute un élément à la pile
// ou le retrouve en cas de reprise // ou le retrouve en cas de reprise

View File

@ -21,7 +21,7 @@
CBotClass* CBotClass::m_ExClass = NULL; CBotClass* CBotClass::m_ExClass = NULL;
CBotClass::CBotClass(const char* name, CBotClass* pPapa, BOOL bIntrinsic) CBotClass::CBotClass(const char* name, CBotClass* pPapa, bool bIntrinsic)
{ {
m_pParent = pPapa; m_pParent = pPapa;
m_name = name; m_name = name;
@ -30,7 +30,7 @@ CBotClass::CBotClass(const char* name, CBotClass* pPapa, BOOL bIntrinsic)
m_pCalls = NULL; m_pCalls = NULL;
m_pMethod = NULL; m_pMethod = NULL;
m_rMaj = NULL; m_rMaj = NULL;
m_IsDef = TRUE; m_IsDef = true;
m_bIntrinsic= bIntrinsic; m_bIntrinsic= bIntrinsic;
m_cptLock = 0; m_cptLock = 0;
m_cptOne = 0; m_cptOne = 0;
@ -86,7 +86,7 @@ void CBotClass::Purge()
m_pCalls = NULL; m_pCalls = NULL;
delete m_pMethod; delete m_pMethod;
m_pMethod = NULL; m_pMethod = NULL;
m_IsDef = FALSE; m_IsDef = false;
m_nbVar = m_pParent == NULL ? 0 : m_pParent->m_nbVar; m_nbVar = m_pParent == NULL ? 0 : m_pParent->m_nbVar;
@ -94,7 +94,7 @@ void CBotClass::Purge()
m_next = NULL; // n'appartient plus à cette chaîne m_next = NULL; // n'appartient plus à cette chaîne
} }
BOOL CBotClass::Lock(CBotProgram* p) bool CBotClass::Lock(CBotProgram* p)
{ {
int i = m_cptLock++; int i = m_cptLock++;
@ -102,13 +102,13 @@ BOOL CBotClass::Lock(CBotProgram* p)
{ {
m_cptOne = 1; m_cptOne = 1;
m_ProgInLock[0] = p; m_ProgInLock[0] = p;
return TRUE; return true;
} }
if ( p == m_ProgInLock[0] ) if ( p == m_ProgInLock[0] )
{ {
m_cptOne++; m_cptOne++;
m_cptLock--; // a déjà été compté m_cptLock--; // a déjà été compté
return TRUE; return true;
} }
for ( int j = 1 ; j <= i ; j++) for ( int j = 1 ; j <= i ; j++)
@ -116,7 +116,7 @@ BOOL CBotClass::Lock(CBotProgram* p)
if ( p == m_ProgInLock[j] ) if ( p == m_ProgInLock[j] )
{ {
m_cptLock--; m_cptLock--;
return FALSE; // déjà en attente return false; // déjà en attente
} }
} }
@ -127,7 +127,7 @@ BOOL CBotClass::Lock(CBotProgram* p)
else else
m_cptLock--; m_cptLock--;
return FALSE; return false;
} }
void CBotClass::Unlock() void CBotClass::Unlock()
@ -170,7 +170,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.GivClass();
@ -194,14 +194,14 @@ BOOL CBotClass::AddItem(CBotString name, CBotTypResult type, int mPrivate)
} }
BOOL CBotClass::AddItem(CBotVar* pVar) bool CBotClass::AddItem(CBotVar* pVar)
{ {
pVar->SetUniqNum(++m_nbVar); pVar->SetUniqNum(++m_nbVar);
if ( m_pVar == NULL ) m_pVar = pVar; if ( m_pVar == NULL ) m_pVar = pVar;
else m_pVar->AddNext(pVar); else m_pVar->AddNext(pVar);
return TRUE; return true;
} }
void CBotClass::AddNext(CBotClass* pClass) void CBotClass::AddNext(CBotClass* pClass)
@ -223,15 +223,15 @@ CBotClass* CBotClass::GivParent()
return m_pParent; return m_pParent;
} }
BOOL CBotClass::IsChildOf(CBotClass* pClass) bool CBotClass::IsChildOf(CBotClass* pClass)
{ {
CBotClass* p = this; CBotClass* p = this;
while ( p != NULL ) while ( p != NULL )
{ {
if ( p == pClass ) return TRUE; if ( p == pClass ) return true;
p = p->m_pParent; p = p->m_pParent;
} }
return FALSE; return false;
} }
@ -266,7 +266,7 @@ CBotVar* CBotClass::GivItemRef(int nIdent)
return NULL; return NULL;
} }
BOOL CBotClass::IsIntrinsic() bool CBotClass::IsIntrinsic()
{ {
return m_bIntrinsic; return m_bIntrinsic;
} }
@ -289,8 +289,8 @@ CBotClass* CBotClass::Find(const char* name)
return NULL; return NULL;
} }
BOOL CBotClass::AddFunction(const char* name, bool CBotClass::AddFunction(const char* name,
BOOL rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception),
CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar)) CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar))
{ {
// mémorise les pointeurs aux deux fonctions // mémorise les pointeurs aux deux fonctions
@ -315,13 +315,13 @@ BOOL CBotClass::AddFunction(const char* name,
if (m_pCalls == NULL) m_pCalls = p; if (m_pCalls == NULL) m_pCalls = p;
else m_pCalls->AddNext(p); // ajoute à la liste else m_pCalls->AddNext(p); // ajoute à la liste
return TRUE; return true;
} }
BOOL CBotClass::AddUpdateFunc( void rMaj ( CBotVar* pThis, void* pUser ) ) bool CBotClass::AddUpdateFunc( void rMaj ( CBotVar* pThis, void* pUser ) )
{ {
m_rMaj = rMaj; m_rMaj = rMaj;
return TRUE; return true;
} }
// compile une méthode associée à une instance de classe // compile une méthode associée à une instance de classe
@ -348,7 +348,7 @@ CBotTypResult CBotClass::CompileMethode(const char* name,
// exécute une méthode // exécute une méthode
BOOL CBotClass::ExecuteMethode(long& nIdent, const char* name, bool CBotClass::ExecuteMethode(long& nIdent, const char* name,
CBotVar* pThis, CBotVar** ppParams, CBotVar* pThis, CBotVar** ppParams,
CBotVar* &pResult, CBotStack* &pStack, CBotVar* &pResult, CBotStack* &pStack,
CBotToken* pToken) CBotToken* pToken)
@ -371,77 +371,77 @@ void CBotClass::RestoreMethode(long& nIdent, const char* name, CBotVar* pThis,
BOOL CBotClass::SaveStaticState(FILE* pf) bool CBotClass::SaveStaticState(FILE* pf)
{ {
if (!WriteWord( pf, CBOTVERSION*2)) return FALSE; if (!WriteWord( pf, CBOTVERSION*2)) return false;
// sauve l'état des variables statiques dans les classes // sauve l'état des variables statiques dans les classes
CBotClass* p = m_ExClass; CBotClass* p = m_ExClass;
while ( p != NULL ) while ( p != NULL )
{ {
if (!WriteWord( pf, 1)) return FALSE; if (!WriteWord( pf, 1)) return false;
// enregistre le nom de la classe // enregistre le nom de la classe
if (!WriteString( pf, p->GivName() )) return FALSE; if (!WriteString( pf, p->GivName() )) return false;
CBotVar* pv = p->GivVar(); CBotVar* pv = p->GivVar();
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->GivName() )) return false;
if ( !pv->Save0State(pf)) return FALSE; // entête commune if ( !pv->Save0State(pf)) return false; // entête commune
if ( !pv->Save1State(pf) ) return FALSE; // sauve selon la classe fille if ( !pv->Save1State(pf) ) return false; // sauve selon la classe fille
if ( !WriteWord( pf, 0)) return FALSE; if ( !WriteWord( pf, 0)) return false;
} }
pv = pv->GivNext(); pv = pv->GivNext();
} }
if (!WriteWord( pf, 0)) return FALSE; if (!WriteWord( pf, 0)) return false;
p = p->m_ExNext; p = p->m_ExNext;
} }
if (!WriteWord( pf, 0)) return FALSE; if (!WriteWord( pf, 0)) return false;
return TRUE; return true;
} }
BOOL CBotClass::RestoreStaticState(FILE* pf) bool CBotClass::RestoreStaticState(FILE* pf)
{ {
CBotString ClassName, VarName; CBotString ClassName, VarName;
CBotClass* pClass; CBotClass* pClass;
WORD w; unsigned short w;
if (!ReadWord( pf, w )) return FALSE; if (!ReadWord( pf, w )) return false;
if ( w != CBOTVERSION*2 ) return FALSE; if ( w != CBOTVERSION*2 ) return false;
while (TRUE) while (true)
{ {
if (!ReadWord( pf, w )) return FALSE; if (!ReadWord( pf, w )) return false;
if ( w == 0 ) return TRUE; if ( w == 0 ) return true;
if (!ReadString( pf, ClassName )) return FALSE; if (!ReadString( pf, ClassName )) return false;
pClass = Find(ClassName); pClass = Find(ClassName);
while (TRUE) while (true)
{ {
if (!ReadWord( pf, w )) return FALSE; if (!ReadWord( pf, w )) return false;
if ( w == 0 ) break; if ( w == 0 ) break;
CBotVar* pVar = NULL; CBotVar* pVar = NULL;
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->GivItem(VarName);
if (!CBotVar::RestoreState(pf, pv)) return FALSE; // la variable temp if (!CBotVar::RestoreState(pf, pv)) return false; // la variable temp
if ( pVar != NULL ) pVar->Copy(pv); if ( pVar != NULL ) pVar->Copy(pv);
delete pv; delete pv;
} }
} }
return TRUE; return true;
} }
@ -453,7 +453,7 @@ CBotClassInst::CBotClassInst()
m_var = NULL; m_var = NULL;
m_Parameters = NULL; m_Parameters = NULL;
m_expr = NULL; m_expr = NULL;
m_hasParams = FALSE; m_hasParams = false;
m_nMethodeIdent = 0; m_nMethodeIdent = 0;
name = "CBotClassInst"; name = "CBotClassInst";
} }
@ -484,18 +484,17 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
p = p->GivNext(); p = p->GivNext();
} }
BOOL bIntrinsic = pClass->IsIntrinsic(); bool bIntrinsic = pClass->IsIntrinsic();
CBotTypResult CBotTypResult type = CBotTypResult( bIntrinsic ? CBotTypIntrinsic : CBotTypPointer, pClass );
type = CBotTypResult( bIntrinsic ? CBotTypIntrinsic : CBotTypPointer,
pClass );
CBotClassInst* inst = (CBotClassInst*)CompileArray(p, pStack, type); CBotClassInst* inst = (CBotClassInst*)CompileArray(p, pStack, type);
if ( inst != NULL || !pStack->IsOk() ) return inst; if ( inst != NULL || !pStack->IsOk() ) return inst;
CBotCStack* pStk = pStack->TokenStack(); CBotCStack* pStk = pStack->TokenStack();
inst = new CBotClassInst(); inst = new CBotClassInst();
/// \TODO Need to be revised and fixed after adding unit tests
inst->SetToken(&pClass->GivName(), p->GivStart(), p->GivEnd()); CBotToken token(pClass->GivName(), CBotString(), p->GivStart(), p->GivEnd());
inst->SetToken(&token);
CBotToken* vartoken = p; CBotToken* vartoken = p;
if ( NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )) ) if ( NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )) )
@ -601,7 +600,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
var->SetPointer( pvar ); // var déjà déclarée pointe l'instance var->SetPointer( pvar ); // var déjà déclarée pointe l'instance
delete pvar; // supprime le second pointeur delete pvar; // supprime le second pointeur
} }
var->SetInit(TRUE); // marque le pointeur comme init var->SetInit(true); // marque le pointeur comme init
} }
else if (inst->m_hasParams) else if (inst->m_hasParams)
{ {
@ -640,17 +639,17 @@ error:
// déclaration de l'instance d'une classe, par exemple: // déclaration de l'instance d'une classe, par exemple:
// CPoint A, B; // CPoint A, B;
BOOL CBotClassInst::Execute(CBotStack* &pj) bool CBotClassInst::Execute(CBotStack* &pj)
{ {
CBotVar* pThis = NULL; CBotVar* pThis = NULL;
CBotStack* pile = pj->AddStack(this);//indispensable pour SetState() CBotStack* pile = pj->AddStack(this);//indispensable pour SetState()
// if ( pile == EOX ) return TRUE; // if ( pile == EOX ) return true;
CBotToken* pt = &m_token; CBotToken* pt = &m_token;
CBotClass* pClass = CBotClass::Find(pt); CBotClass* pClass = CBotClass::Find(pt);
BOOL bIntrincic = pClass->IsIntrinsic(); bool bIntrincic = pClass->IsIntrinsic();
// crée la variable de type pointeur à l'objet // crée la variable de type pointeur à l'objet
@ -682,7 +681,7 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
if ( m_expr != NULL ) if ( m_expr != NULL )
{ {
// évalue l'expression pour l'assignation // évalue l'expression pour l'assignation
if (!m_expr->Execute(pile)) return FALSE; if (!m_expr->Execute(pile)) return false;
if ( bIntrincic ) if ( bIntrincic )
{ {
@ -692,7 +691,7 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
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->GivVar(), false);
} }
else else
{ {
@ -700,7 +699,7 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
pInstance = ((CBotVarPointer*)pile->GivVar())->GivPointer(); // valeur pour l'assignation pInstance = ((CBotVarPointer*)pile->GivVar())->GivPointer(); // valeur pour l'assignation
pThis->SetPointer(pInstance); pThis->SetPointer(pInstance);
} }
pThis->SetInit(TRUE); pThis->SetInit(true);
} }
else if ( m_hasParams ) else if ( m_hasParams )
@ -732,12 +731,12 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
// et place les valeurs sur la pile // et place les valeurs sur la pile
// pour pouvoir être interrompu n'importe quand // pour pouvoir être interrompu n'importe quand
if ( p != NULL) while ( TRUE ) if ( p != NULL) while ( true )
{ {
pile2 = pile2->AddStack(); // de la place sur la pile pour les résultats pile2 = pile2->AddStack(); // de la place sur la pile pour les résultats
if ( pile2->GivState() == 0 ) if ( pile2->GivState() == 0 )
{ {
if (!p->Execute(pile2)) return FALSE; // interrompu ici ? if (!p->Execute(pile2)) return false; // interrompu ici ?
pile2->SetState(1); pile2->SetState(1);
} }
ppVars[i++] = pile2->GivVar(); ppVars[i++] = pile2->GivVar();
@ -751,9 +750,9 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GivName(), if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GivName(),
pThis, ppVars, pThis, ppVars,
pResult, pile2, GivToken())) return FALSE; // interrompu pResult, pile2, GivToken())) return false; // interrompu
pThis->SetInit(TRUE); pThis->SetInit(true);
pThis->ConstructorSet(); // signale que le constructeur a été appelé pThis->ConstructorSet(); // signale que le constructeur a été appelé
pile->Return(pile2); // libère un bout de pile pile->Return(pile2); // libère un bout de pile
@ -766,17 +765,17 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
pile->SetState(3); // fini cette partie pile->SetState(3); // fini cette partie
} }
if ( pile->IfStep() ) return FALSE; if ( pile->IfStep() ) return false;
if ( m_next2b != NULL && if ( m_next2b != NULL &&
!m_next2b->Execute(pile)) return FALSE; // autre(s) définition(s) !m_next2b->Execute(pile)) return false; // autre(s) définition(s)
return pj->Return( pile ); // transmet en dessous return pj->Return( pile ); // transmet en dessous
} }
void CBotClassInst::RestoreState(CBotStack* &pj, BOOL bMain) void CBotClassInst::RestoreState(CBotStack* &pj, bool bMain)
{ {
CBotVar* pThis = NULL; CBotVar* pThis = NULL;
@ -793,7 +792,7 @@ void CBotClassInst::RestoreState(CBotStack* &pj, BOOL bMain)
CBotToken* pt = &m_token; CBotToken* pt = &m_token;
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->GivState()<3)
{ {
@ -827,7 +826,7 @@ void CBotClassInst::RestoreState(CBotStack* &pj, BOOL bMain)
// et place les valeurs sur la pile // et place les valeurs sur la pile
// pour pouvoir être interrompu n'importe quand // pour pouvoir être interrompu n'importe quand
if ( p != NULL) while ( TRUE ) if ( p != NULL) while ( true )
{ {
pile2 = pile2->RestoreStack(); // de la place sur la pile pour les résultats pile2 = pile2->RestoreStack(); // de la place sur la pile pour les résultats
if ( pile2 == NULL ) return; if ( pile2 == NULL ) return;
@ -858,11 +857,11 @@ void CBotClassInst::RestoreState(CBotStack* &pj, BOOL bMain)
// test si un nom de procédure est déjà défini quelque part // test si un nom de procédure est déjà défini quelque part
BOOL CBotClass::CheckCall(CBotToken* &pToken, CBotDefParam* pParam) bool CBotClass::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
{ {
CBotString name = pToken->GivString(); CBotString name = pToken->GivString();
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 )
@ -871,11 +870,11 @@ BOOL CBotClass::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
{ {
// les paramètres sont-ils exactement les mêmes ? // les paramètres sont-ils exactement les mêmes ?
if ( pp->CheckParam( pParam ) ) if ( pp->CheckParam( pParam ) )
return TRUE; return true;
} }
pp = pp->Next(); pp = pp->Next();
} }
return FALSE; return false;
} }

View File

@ -83,7 +83,7 @@ CBotInstr* CBotCompExpr::Compile(CBotToken* &p, CBotCStack* pStack)
// fait l'opération // fait l'opération
BOOL CBotCompExpr::Execute(CBotStack* &pStack) bool CBotCompExpr::Execute(CBotStack* &pStack)
{ {
CBotStack* pStk1 = pStack->AddStack(this); CBotStack* pStk1 = pStack->AddStack(this);
// if ( pStk1 == EOX ) return TRUE; // if ( pStk1 == EOX ) return TRUE;

File diff suppressed because it is too large Load Diff

View File

@ -25,14 +25,14 @@ CBotFunction::CBotFunction()
m_Param = NULL; // liste des paramètres vide m_Param = NULL; // liste des paramètres vide
m_Block = NULL; // le bloc d'instructions m_Block = NULL; // le bloc d'instructions
m_next = NULL; // les fonctions peuvent être chaînées m_next = NULL; // les fonctions peuvent être chaînées
m_bPublic = FALSE; // fonction non publique m_bPublic = false; // fonction non publique
m_bExtern = FALSE; // fonction non externe m_bExtern = false; // fonction non externe
m_nextpublic = NULL; m_nextpublic = NULL;
m_prevpublic = NULL; m_prevpublic = NULL;
m_pProg = NULL; m_pProg = NULL;
// m_nThisIdent = 0; // m_nThisIdent = 0;
m_nFuncIdent = 0; m_nFuncIdent = 0;
m_bSynchro = FALSE; m_bSynchro = false;
} }
CBotFunction* CBotFunction::m_listPublic = NULL; CBotFunction* CBotFunction::m_listPublic = NULL;
@ -62,17 +62,17 @@ CBotFunction::~CBotFunction()
} }
} }
BOOL CBotFunction::IsPublic() bool CBotFunction::IsPublic()
{ {
return m_bPublic; return m_bPublic;
} }
BOOL CBotFunction::IsExtern() bool CBotFunction::IsExtern()
{ {
return m_bExtern; return m_bExtern;
} }
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.GivStart();
stop = m_closeblk.GivEnd(); stop = m_closeblk.GivEnd();
@ -110,7 +110,7 @@ BOOL CBotFunction::GetPosition(int& start, int& stop, CBotGet modestart, CBotGet
stop = m_closeblk.GivEnd(); stop = m_closeblk.GivEnd();
} }
return TRUE; return true;
} }
@ -168,7 +168,7 @@ CBotTypResult TypeParam(CBotToken* &p, CBotCStack* pile)
// compile une nouvelle fonction // compile une nouvelle fonction
// bLocal permet de mettre la déclaration des paramètres au même niveau // bLocal permet de mettre la déclaration des paramètres au même niveau
// que le éléments appartenant à la classe pour les méthodes // que le éléments appartenant à la classe pour les méthodes
CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunction* finput, BOOL bLocal) CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunction* finput, bool bLocal)
{ {
CBotToken* pp; CBotToken* pp;
CBotFunction* func = finput; CBotFunction* func = finput;
@ -178,19 +178,19 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
// func->m_nFuncIdent = CBotVar::NextUniqNum(); // func->m_nFuncIdent = CBotVar::NextUniqNum();
while (TRUE) while (true)
{ {
if ( IsOfType(p, ID_PUBLIC) ) if ( IsOfType(p, ID_PUBLIC) )
{ {
func->m_bPublic = TRUE; func->m_bPublic = true;
continue; continue;
} }
pp = p; pp = p;
if ( IsOfType(p, ID_EXTERN) ) if ( IsOfType(p, ID_EXTERN) )
{ {
func->m_extern = pp; // pour la position du mot "extern" func->m_extern = pp; // pour la position du mot "extern"
func->m_bExtern = TRUE; func->m_bExtern = true;
// func->m_bPublic = TRUE; // donc aussi publique! // func->m_bPublic = true; // donc aussi publique!
continue; continue;
} }
break; break;
@ -260,7 +260,7 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
// et compile le bloc d'instruction qui suit // et compile le bloc d'instruction qui suit
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->GivPrev();
if ( pStk->IsOk() ) if ( pStk->IsOk() )
{ {
@ -286,18 +286,18 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
CBotFunction* func = new CBotFunction(); CBotFunction* func = new CBotFunction();
func->m_nFuncIdent = CBotVar::NextUniqNum(); func->m_nFuncIdent = CBotVar::NextUniqNum();
CBotCStack* pStk = pStack->TokenStack(p, TRUE); CBotCStack* pStk = pStack->TokenStack(p, true);
while (TRUE) while (true)
{ {
if ( IsOfType(p, ID_PUBLIC) ) if ( IsOfType(p, ID_PUBLIC) )
{ {
// func->m_bPublic = TRUE; // sera fait en passe 2 // func->m_bPublic = true; // sera fait en passe 2
continue; continue;
} }
if ( IsOfType(p, ID_EXTERN) ) if ( IsOfType(p, ID_EXTERN) )
{ {
func->m_bExtern = TRUE; func->m_bExtern = true;
continue; continue;
} }
break; break;
@ -367,16 +367,16 @@ bad:
static int xx = 0; static int xx = 0;
#endif #endif
BOOL CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance) bool CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance)
{ {
CBotStack* pile = pj->AddStack(this, 2); // un bout de pile local à cette fonction CBotStack* pile = pj->AddStack(this, 2); // un bout de pile local à cette fonction
// if ( pile == EOX ) return TRUE; // if ( pile == EOX ) return true;
pile->SetBotCall(m_pProg); // bases pour les routines pile->SetBotCall(m_pProg); // bases pour les routines
if ( pile->GivState() == 0 ) if ( pile->GivState() == 0 )
{ {
if ( !m_Param->Execute(ppVars, pile) ) return FALSE; // défini les paramètres if ( !m_Param->Execute(ppVars, pile) ) return false; // défini les paramètres
pile->IncState(); pile->IncState();
} }
@ -403,14 +403,14 @@ BOOL CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance)
pile->IncState(); pile->IncState();
} }
if ( pile->IfStep() ) return FALSE; if ( pile->IfStep() ) return false;
if ( !m_Block->Execute(pile) ) if ( !m_Block->Execute(pile) )
{ {
if ( pile->GivError() < 0 ) if ( pile->GivError() < 0 )
pile->SetError( 0 ); pile->SetError( 0 );
else else
return FALSE; return false;
} }
return pj->Return(pile); return pj->Return(pile);
@ -433,7 +433,7 @@ void CBotFunction::RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInst
pile2->Delete(); pile2->Delete();
} }
m_Param->RestoreState(pile2, TRUE); // les paramètres m_Param->RestoreState(pile2, true); // les paramètres
if ( !m_MasterClass.IsEmpty() ) if ( !m_MasterClass.IsEmpty() )
{ {
@ -442,7 +442,7 @@ void CBotFunction::RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInst
pThis->SetUniqNum(-2); pThis->SetUniqNum(-2);
} }
m_Block->RestoreState(pile2, TRUE); m_Block->RestoreState(pile2, true);
} }
void CBotFunction::AddNext(CBotFunction* p) void CBotFunction::AddNext(CBotFunction* p)
@ -467,7 +467,7 @@ CBotTypResult CBotFunction::CompileCall(const char* name, CBotVar** ppVars, long
// trouve une fonction selon son identificateur unique // trouve une fonction selon son identificateur unique
// si l'identificateur n'est pas trouvé, cherche selon le nom et les paramètres // si l'identificateur n'est pas trouvé, cherche selon le nom et les paramètres
CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CBotVar** ppVars, CBotTypResult& TypeOrError, BOOL bPublic) CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CBotVar** ppVars, CBotTypResult& TypeOrError, bool bPublic)
{ {
TypeOrError.SetType(TX_UNDEFCALL); // pas de routine de ce nom TypeOrError.SetType(TX_UNDEFCALL); // pas de routine de ce nom
CBotFunction* pt; CBotFunction* pt;
@ -632,13 +632,13 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar** ppVars, CBotS
if ( pt != NULL ) if ( pt != NULL )
{ {
CBotStack* pStk1 = pStack->AddStack(pt, 2); // pour mettre "this" CBotStack* pStk1 = pStack->AddStack(pt, 2); // pour mettre "this"
// if ( pStk1 == EOX ) return TRUE; // if ( pStk1 == EOX ) return true;
pStk1->SetBotCall(pt->m_pProg); // on a peut-être changé de module pStk1->SetBotCall(pt->m_pProg); // on a peut-être changé de module
if ( pStk1->IfStep() ) return FALSE; if ( pStk1->IfStep() ) return false;
CBotStack* pStk3 = pStk1->AddStack(NULL, TRUE); // paramètres CBotStack* pStk3 = pStk1->AddStack(NULL, true); // paramètres
// prépare les paramètres sur la pile // prépare les paramètres sur la pile
@ -680,11 +680,11 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar** ppVars, CBotS
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->GivFunctions()->GivName() == "LaCommande" ) return false;
#endif #endif
pStk3->SetPosError(pToken); // indique l'erreur sur l'appel de procédure pStk3->SetPosError(pToken); // indique l'erreur sur l'appel de procédure
} }
return FALSE; // interrompu ! return false; // interrompu !
} }
return pStack->Return( pStk3 ); return pStack->Return( pStk3 );
@ -738,13 +738,13 @@ void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar** ppVars,
if ( pStk1->GivState() == 0 ) if ( pStk1->GivState() == 0 )
{ {
pt->m_Param->RestoreState(pStk3, TRUE); pt->m_Param->RestoreState(pStk3, true);
return; return;
} }
// initialise les variables selon paramètres // initialise les variables selon paramètres
pt->m_Param->RestoreState(pStk3, FALSE); pt->m_Param->RestoreState(pStk3, false);
pt->m_Block->RestoreState(pStk3, TRUE); pt->m_Block->RestoreState(pStk3, true);
} }
} }
@ -758,17 +758,17 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
CBotTypResult type; CBotTypResult type;
CBotProgram* pProgCurrent = pStack->GivBotCall(); CBotProgram* pProgCurrent = pStack->GivBotCall();
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->GivName(), 0, pStack);
CBotStack* pStk = pStack->AddStack(pt, 2); CBotStack* pStk = pStack->AddStack(pt, 2);
// if ( pStk == EOX ) return TRUE; // if ( pStk == EOX ) return true;
pStk->SetBotCall(pt->m_pProg); // on a peut-être changé de module pStk->SetBotCall(pt->m_pProg); // on a peut-être changé de module
CBotStack* pStk3 = pStk->AddStack(NULL, TRUE); // pour mettre les paramètres passés CBotStack* pStk3 = pStk->AddStack(NULL, true); // pour mettre les paramètres passés
// prépare les paramètres sur la pile // prépare les paramètres sur la pile
@ -776,7 +776,7 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
{ {
// met la variable "this" sur la pile // met la variable "this" sur la pile
CBotVar* pthis = CBotVar::Create("this", CBotTypNullPointer); CBotVar* pthis = CBotVar::Create("this", CBotTypNullPointer);
pthis->Copy(pThis, FALSE); pthis->Copy(pThis, false);
pthis->SetUniqNum(-2); // valeur spéciale pthis->SetUniqNum(-2); // valeur spéciale
pStk->AddVar(pthis); pStk->AddVar(pthis);
@ -785,7 +785,7 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
{ {
// met la variable "super" sur la pile // met la variable "super" sur la pile
CBotVar* psuper = CBotVar::Create("super", CBotTypNullPointer); CBotVar* psuper = CBotVar::Create("super", CBotTypNullPointer);
psuper->Copy(pThis, FALSE); // en fait identique à "this" psuper->Copy(pThis, false); // en fait identique à "this"
psuper->SetUniqNum(-3); // valeur spéciale psuper->SetUniqNum(-3); // valeur spéciale
pStk->AddVar(psuper); pStk->AddVar(psuper);
} }
@ -798,8 +798,8 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
{ {
if ( pt->m_bSynchro ) if ( pt->m_bSynchro )
{ {
CBotProgram* pProgBase = pStk->GivBotCall(TRUE); CBotProgram* pProgBase = pStk->GivBotCall(true);
if ( !pClass->Lock(pProgBase) ) return FALSE; // attend de pouvoir if ( !pClass->Lock(pProgBase) ) return false; // attend de pouvoir
} }
pStk->IncState(); pStk->IncState();
} }
@ -820,7 +820,7 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
pStk3->SetPosError(pToken); // indique l'erreur sur l'appel de procédure pStk3->SetPosError(pToken); // indique l'erreur sur l'appel de procédure
} }
} }
return FALSE; // interrompu ! return false; // interrompu !
} }
if ( pt->m_bSynchro ) if ( pt->m_bSynchro )
@ -850,30 +850,30 @@ void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar* pThis, C
CBotStack* pStk3 = pStk->RestoreStack(NULL); // pour mettre les paramètres passés CBotStack* pStk3 = pStk->RestoreStack(NULL); // pour mettre les paramètres passés
if ( pStk3 == NULL ) return; if ( pStk3 == NULL ) return;
pt->m_Param->RestoreState(pStk3, TRUE); // les paramètres pt->m_Param->RestoreState(pStk3, true); // les paramètres
if ( pStk->GivState() > 1 && // vérouillage est effectif ? if ( pStk->GivState() > 1 && // vérouillage est effectif ?
pt->m_bSynchro ) pt->m_bSynchro )
{ {
CBotProgram* pProgBase = pStk->GivBotCall(TRUE); CBotProgram* pProgBase = pStk->GivBotCall(true);
pClass->Lock(pProgBase); // vérouille la classe pClass->Lock(pProgBase); // vérouille la classe
} }
// finalement appelle la fonction trouvée // finalement appelle la fonction trouvée
pt->m_Block->RestoreState(pStk3, TRUE); // interrompu ! pt->m_Block->RestoreState(pStk3, true); // interrompu !
} }
} }
// regarde si la "signature" des paramètres est identique // regarde si la "signature" des paramètres est identique
BOOL CBotFunction::CheckParam(CBotDefParam* pParam) 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->GivType();
CBotTypResult type2 = pParam->GivType(); CBotTypResult type2 = pParam->GivType();
if ( !type1.Compare(type2) ) return FALSE; if ( !type1.Compare(type2) ) return false;
pp = pp->GivNext(); pp = pp->GivNext();
pParam = pParam->GivNext(); pParam = pParam->GivNext();
} }
@ -1005,7 +1005,7 @@ void CBotDefParam::AddNext(CBotDefParam* p)
} }
BOOL CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj) bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
{ {
int i = 0; int i = 0;
CBotDefParam* p = this; CBotDefParam* p = this;
@ -1033,7 +1033,7 @@ BOOL CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
newvar->SetValInt(ppVars[i]->GivValInt()); newvar->SetValInt(ppVars[i]->GivValInt());
break; break;
case CBotTypIntrinsic: case CBotTypIntrinsic:
((CBotVarClass*)newvar)->Copy(ppVars[i], FALSE); ((CBotVarClass*)newvar)->Copy(ppVars[i], false);
break; break;
case CBotTypPointer: case CBotTypPointer:
case CBotTypArrayPointer: case CBotTypArrayPointer:
@ -1051,10 +1051,10 @@ BOOL CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
i++; i++;
} }
return TRUE; return true;
} }
void CBotDefParam::RestoreState(CBotStack* &pj, BOOL bMain) void CBotDefParam::RestoreState(CBotStack* &pj, bool bMain)
{ {
int i = 0; int i = 0;
CBotDefParam* p = this; CBotDefParam* p = this;
@ -1146,25 +1146,25 @@ CBotInstr* CBotReturn::Compile(CBotToken* &p, CBotCStack* pStack)
return NULL; // pas d'objet, l'erreur est sur la pile return NULL; // pas d'objet, l'erreur est sur la pile
} }
BOOL CBotReturn::Execute(CBotStack* &pj) 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->GivState() == 0 )
{ {
if ( m_Instr != NULL && !m_Instr->Execute(pile) ) return FALSE; // évalue le résultat if ( m_Instr != NULL && !m_Instr->Execute(pile) ) return false; // évalue le résultat
// le résultat est sur la pile // le résultat est sur la pile
pile->IncState(); pile->IncState();
} }
if ( pile->IfStep() ) return FALSE; if ( pile->IfStep() ) return false;
pile->SetBreak(3, CBotString()); pile->SetBreak(3, CBotString());
return pj->Return(pile); return pj->Return(pile);
} }
void CBotReturn::RestoreState(CBotStack* &pj, BOOL bMain) void CBotReturn::RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
CBotStack* pile = pj->RestoreStack(this); CBotStack* pile = pj->RestoreStack(this);
@ -1211,7 +1211,7 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
inst->SetToken(pp); inst->SetToken(pp);
// compile la liste des paramètres // compile la liste des paramètres
if (!IsOfType(p, ID_CLOSEPAR)) while (TRUE) if (!IsOfType(p, ID_CLOSEPAR)) while (true)
{ {
start = p->GivStart(); start = p->GivStart();
pile = pile->TokenStack(); // garde les résultats sur la pile pile = pile->TokenStack(); // garde les résultats sur la pile
@ -1278,7 +1278,7 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
return NULL; return NULL;
} }
BOOL CBotInstrCall::Execute(CBotStack* &pj) bool CBotInstrCall::Execute(CBotStack* &pj)
{ {
CBotVar* ppVars[1000]; CBotVar* ppVars[1000];
CBotStack* pile = pj->AddStack(this); CBotStack* pile = pj->AddStack(this);
@ -1292,12 +1292,12 @@ BOOL CBotInstrCall::Execute(CBotStack* &pj)
// évalue les paramètres // évalue les paramètres
// et place les valeurs sur la pile // et place les valeurs sur la pile
// pour pouvoir être interrompu n'importe quand // pour pouvoir être interrompu n'importe quand
if ( p != NULL) while ( TRUE ) if ( p != NULL) while ( true )
{ {
pile = pile->AddStack(); // de la place sur la pile pour les résultats pile = pile->AddStack(); // de la place sur la pile pour les résultats
if ( pile->GivState() == 0 ) if ( pile->GivState() == 0 )
{ {
if (!p->Execute(pile)) return FALSE; // interrompu ici ? if (!p->Execute(pile)) return false; // interrompu ici ?
pile->SetState(1); // marque spéciale pour reconnaîre les paramètres pile->SetState(1); // marque spéciale pour reconnaîre les paramètres
} }
ppVars[i++] = pile->GivVar(); ppVars[i++] = pile->GivVar();
@ -1307,14 +1307,14 @@ BOOL CBotInstrCall::Execute(CBotStack* &pj)
ppVars[i] = NULL; ppVars[i] = NULL;
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; // interrompu if ( !pile2->ExecuteCall(m_nFuncIdent, GivToken(), ppVars, m_typRes)) return false; // interrompu
return pj->Return(pile2); // libère toute la pile return pj->Return(pile2); // libère toute la pile
} }
void CBotInstrCall::RestoreState(CBotStack* &pj, BOOL bMain) void CBotInstrCall::RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
@ -1329,7 +1329,7 @@ void CBotInstrCall::RestoreState(CBotStack* &pj, BOOL bMain)
// évalue les paramètres // évalue les paramètres
// et place les valeurs sur la pile // et place les valeurs sur la pile
// pour pouvoir être interrompu n'importe quand // pour pouvoir être interrompu n'importe quand
if ( p != NULL) while ( TRUE ) if ( p != NULL) while ( true )
{ {
pile = pile->RestoreStack(); // de la place sur la pile pour les résultats pile = pile->RestoreStack(); // de la place sur la pile pour les résultats
if ( pile == NULL ) return; if ( pile == NULL ) return;
@ -1379,7 +1379,6 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
if (IsOfType(p, TokenTypVar)) if (IsOfType(p, TokenTypVar))
{ {
CBotClass* pPapa = NULL; CBotClass* pPapa = NULL;
#if EXTENDS
if ( IsOfType( p, ID_EXTENDS ) ) if ( IsOfType( p, ID_EXTENDS ) )
{ {
CBotString name = p->GivString(); CBotString name = p->GivString();
@ -1391,10 +1390,9 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
return NULL; return NULL;
} }
} }
#endif
CBotClass* classe = (pOld == NULL) ? new CBotClass(name, pPapa) : pOld; CBotClass* classe = (pOld == NULL) ? new CBotClass(name, pPapa) : pOld;
classe->Purge(); // vide les anciennes définitions classe->Purge(); // vide les anciennes définitions
classe->m_IsDef = FALSE; // définition en cours classe->m_IsDef = false; // définition en cours
if ( !IsOfType( p, ID_OPBLK) ) if ( !IsOfType( p, ID_OPBLK) )
{ {
@ -1404,7 +1402,7 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
while ( pStack->IsOk() && !IsOfType( p, ID_CLBLK ) ) while ( pStack->IsOk() && !IsOfType( p, ID_CLBLK ) )
{ {
classe->CompileDefItem(p, pStack, FALSE); classe->CompileDefItem(p, pStack, false);
} }
if (pStack->IsOk()) return classe; if (pStack->IsOk()) return classe;
@ -1413,24 +1411,24 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
return NULL; return NULL;
} }
BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond) bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
{ {
BOOL bStatic = FALSE; bool bStatic = false;
int mProtect = PR_PUBLIC; int mProtect = PR_PUBLIC;
BOOL bSynchro = FALSE; bool bSynchro = false;
while (IsOfType(p, ID_SEP)) ; while (IsOfType(p, ID_SEP)) ;
CBotTypResult type( -1 ); CBotTypResult type( -1 );
if ( IsOfType(p, ID_SYNCHO) ) bSynchro = TRUE; if ( IsOfType(p, ID_SYNCHO) ) bSynchro = true;
CBotToken* pBase = p; CBotToken* pBase = p;
if ( IsOfType(p, ID_STATIC) ) bStatic = TRUE; if ( IsOfType(p, ID_STATIC) ) bStatic = true;
if ( IsOfType(p, ID_PUBLIC) ) mProtect = PR_PUBLIC; if ( IsOfType(p, ID_PUBLIC) ) mProtect = PR_PUBLIC;
if ( IsOfType(p, ID_PRIVATE) ) mProtect = PR_PRIVATE; if ( IsOfType(p, ID_PRIVATE) ) mProtect = PR_PRIVATE;
if ( IsOfType(p, ID_PROTECTED) ) mProtect = PR_PROTECT; if ( IsOfType(p, ID_PROTECTED) ) mProtect = PR_PROTECT;
if ( IsOfType(p, ID_STATIC) ) bStatic = TRUE; if ( IsOfType(p, ID_STATIC) ) bStatic = true;
// CBotClass* pClass = NULL; // CBotClass* pClass = NULL;
type = TypeParam(p, pStack); // type du résultat type = TypeParam(p, pStack); // type du résultat
@ -1438,7 +1436,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
if ( type.Eq(-1) ) if ( type.Eq(-1) )
{ {
pStack->SetError(TX_NOTYP, p); pStack->SetError(TX_NOTYP, p);
return FALSE; return false;
} }
while (pStack->IsOk()) while (pStack->IsOk())
@ -1463,14 +1461,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->GivStart());
return FALSE; return false;
} }
/* CBotVar* pv = pStack->GivVar(); /* CBotVar* pv = pStack->GivVar();
if ( pv->GivType()>= CBotTypBoolean ) if ( pv->GivType()>= CBotTypBoolean )
{ {
pStack->SetError(TX_BADTYPE, p->GivStart()); pStack->SetError(TX_BADTYPE, p->GivStart());
return FALSE; return false;
}*/ }*/
if (limites == NULL) limites = i; if (limites == NULL) limites = i;
@ -1485,7 +1483,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
CBotFunction* f = CBotFunction* f =
CBotFunction::Compile1(p, pStack, this); CBotFunction::Compile1(p, pStack, this);
if ( f == NULL ) return FALSE; if ( f == NULL ) return false;
if (m_pMethod == NULL) m_pMethod = f; if (m_pMethod == NULL) m_pMethod = f;
else m_pMethod->AddNext(f); else m_pMethod->AddNext(f);
@ -1502,8 +1500,8 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
pf = pf->Next(); pf = pf->Next();
} }
BOOL bConstructor = (pp->GivString() == GivName()); bool bConstructor = (pp->GivString() == GivName());
CBotCStack* pile = pStack->TokenStack(NULL, TRUE); CBotCStack* pile = pStack->TokenStack(NULL, true);
// rend "this" connu // rend "this" connu
CBotToken TokenThis(CBotString("this"), CBotString()); CBotToken TokenThis(CBotString("this"), CBotString());
@ -1540,7 +1538,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
// compile une méthode // compile une méthode
p = pBase; p = pBase;
CBotFunction* f = CBotFunction* f =
CBotFunction::Compile(p, pile, NULL/*, FALSE*/); CBotFunction::Compile(p, pile, NULL/*, false*/);
if ( f != NULL ) if ( f != NULL )
{ {
@ -1563,7 +1561,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
if (type.Eq(0)) if (type.Eq(0))
{ {
pStack->SetError(TX_ENDOF, p); pStack->SetError(TX_ENDOF, p);
return FALSE; return false;
} }
CBotInstr* i = NULL; CBotInstr* i = NULL;
@ -1578,7 +1576,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
// il y a une assignation à calculer // il y a une assignation à calculer
i = CBotTwoOpExpr::Compile(p, pStack); i = CBotTwoOpExpr::Compile(p, pStack);
} }
if ( !pStack->IsOk() ) return FALSE; if ( !pStack->IsOk() ) return false;
} }
@ -1627,20 +1625,18 @@ CBotClass* CBotClass::Compile(CBotToken* &p, CBotCStack* pStack)
// la classe à été créée par Compile1 // la classe à été créée par Compile1
CBotClass* pOld = CBotClass::Find(name); CBotClass* pOld = CBotClass::Find(name);
#if EXTENDS
if ( IsOfType( p, ID_EXTENDS ) ) if ( IsOfType( p, ID_EXTENDS ) )
{ {
IsOfType(p, TokenTypVar); // forcément IsOfType(p, TokenTypVar); // forcément
} }
#endif
IsOfType( p, ID_OPBLK); // forcément IsOfType( p, ID_OPBLK); // forcément
while ( pStack->IsOk() && !IsOfType( p, ID_CLBLK ) ) while ( pStack->IsOk() && !IsOfType( p, ID_CLBLK ) )
{ {
pOld->CompileDefItem(p, pStack, TRUE); pOld->CompileDefItem(p, pStack, true);
} }
pOld->m_IsDef = TRUE; // définition terminée pOld->m_IsDef = true; // définition terminée
if (pStack->IsOk()) return pOld; if (pStack->IsOk()) return pOld;
} }
pStack->SetError(TX_ENDOF, p); pStack->SetError(TX_ENDOF, p);

View File

@ -51,7 +51,7 @@ CBotInstr* CBotIf::Compile(CBotToken* &p, CBotCStack* pStack)
{ {
// la condition existe bel et bien // la condition existe bel et bien
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true );
if ( pStk->IsOk() ) if ( pStk->IsOk() )
{ {
// le bloc d'instruction est ok (peut être vide) // le bloc d'instruction est ok (peut être vide)
@ -60,7 +60,7 @@ CBotInstr* CBotIf::Compile(CBotToken* &p, CBotCStack* pStack)
if (IsOfType(p, ID_ELSE)) if (IsOfType(p, ID_ELSE))
{ {
// si oui, compile le bloc d'instruction qui suit // si oui, compile le bloc d'instruction qui suit
inst->m_BlockElse = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); inst->m_BlockElse = CBotBlock::CompileBlkOrInst( p, pStk, true );
if (!pStk->IsOk()) if (!pStk->IsOk())
{ {
// il n'y a pas de bloc correct après le else // il n'y a pas de bloc correct après le else
@ -84,19 +84,19 @@ CBotInstr* CBotIf::Compile(CBotToken* &p, CBotCStack* pStack)
// exécution de l'instruction // exécution de l'instruction
BOOL CBotIf :: Execute(CBotStack* &pj) bool CBotIf :: Execute(CBotStack* &pj)
{ {
CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile
// ou le retrouve en cas de reprise // ou le retrouve en cas de reprise
// if ( pile == EOX ) return TRUE; // if ( pile == EOX ) return true;
if ( pile->IfStep() ) return FALSE; if ( pile->IfStep() ) return false;
// selon la reprise, on peut être dans l'un des 2 états // selon la reprise, on peut être dans l'un des 2 états
if( pile->GivState() == 0 ) if( pile->GivState() == 0 )
{ {
// évalue la condition // évalue la condition
if ( !m_Condition->Execute(pile) ) return FALSE; // interrompu ici ? if ( !m_Condition->Execute(pile) ) return false; // interrompu ici ?
// termine s'il y a une erreur // termine s'il y a une erreur
if ( !pile->IsOk() ) if ( !pile->IsOk() )
@ -105,21 +105,21 @@ BOOL CBotIf :: Execute(CBotStack* &pj)
} }
// passe dans le second état // passe dans le second état
if (!pile->SetState(1)) return FALSE; // prêt pour la suite if (!pile->SetState(1)) return false; // prêt pour la suite
} }
// second état, évalue les instructions associées // second état, évalue les instructions associées
// le résultat de la condition est sur la pile // le résultat de la condition est sur la pile
if ( pile->GivVal() == TRUE ) // condition était vraie ? if ( pile->GivVal() == true ) // condition était vraie ?
{ {
if ( m_Block != NULL && // bloc peut être absent if ( m_Block != NULL && // bloc peut être absent
!m_Block->Execute(pile) ) return FALSE; // interrompu ici ? !m_Block->Execute(pile) ) return false; // interrompu ici ?
} }
else else
{ {
if ( m_BlockElse != NULL && // s'il existe un bloc alternatif if ( m_BlockElse != NULL && // s'il existe un bloc alternatif
!m_BlockElse->Execute(pile) ) return FALSE; // interrompu ici !m_BlockElse->Execute(pile) ) return false; // interrompu ici
} }
// transmet le résultat et libère la pile // transmet le résultat et libère la pile
@ -127,7 +127,7 @@ BOOL CBotIf :: Execute(CBotStack* &pj)
} }
void CBotIf :: RestoreState(CBotStack* &pj, BOOL bMain) void CBotIf :: RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
@ -145,7 +145,7 @@ void CBotIf :: RestoreState(CBotStack* &pj, BOOL bMain)
// second état, évalue les instructions associées // second état, évalue les instructions associées
// le résultat de la condition est sur la pile // le résultat de la condition est sur la pile
if ( pile->GivVal() == TRUE ) // condition était vraie ? if ( pile->GivVal() == true ) // condition était vraie ?
{ {
if ( m_Block != NULL ) // bloc peut être absent if ( m_Block != NULL ) // bloc peut être absent
m_Block->RestoreState(pile, bMain); // interrompu ici ! m_Block->RestoreState(pile, bMain); // interrompu ici !

View File

@ -62,7 +62,7 @@ CBotProgram::~CBotProgram()
} }
BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions, void* pUser ) bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions, void* pUser )
{ {
int error = 0; int error = 0;
Stop(); Stop();
@ -81,7 +81,7 @@ BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
// transforme le programme en Tokens // transforme le programme en Tokens
CBotToken* pBaseToken = CBotToken::CompileTokens(program, error); CBotToken* pBaseToken = CBotToken::CompileTokens(program, error);
if ( pBaseToken == NULL ) return FALSE; if ( pBaseToken == NULL ) return false;
CBotCStack* pStack = new CBotCStack(NULL); CBotCStack* pStack = new CBotCStack(NULL);
@ -115,7 +115,7 @@ BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
delete m_Prog; delete m_Prog;
m_Prog = NULL; m_Prog = NULL;
delete pBaseToken; delete pBaseToken;
return FALSE; return false;
} }
// CBotFunction* temp = NULL; // CBotFunction* temp = NULL;
@ -130,12 +130,12 @@ BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
if ( p->GivType() == ID_CLASS || if ( p->GivType() == ID_CLASS ||
( p->GivType() == ID_PUBLIC && p->GivNext()->GivType() == ID_CLASS )) ( p->GivType() == ID_PUBLIC && p->GivNext()->GivType() == ID_CLASS ))
{ {
m_bCompileClass = TRUE; m_bCompileClass = true;
CBotClass::Compile(p, pStack); // complète la définition de la classe CBotClass::Compile(p, pStack); // complète la définition de la classe
} }
else else
{ {
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->GivName()/* + next->GivParams()*/);
next->m_pProg = this; // garde le pointeur au module next->m_pProg = this; // garde le pointeur au module
@ -160,7 +160,7 @@ BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
} }
BOOL CBotProgram::Start(const char* name) bool CBotProgram::Start(const char* name)
{ {
#if STACKMEM #if STACKMEM
m_pStack->Delete(); m_pStack->Delete();
@ -179,7 +179,7 @@ BOOL CBotProgram::Start(const char* name)
if ( m_pRun == NULL ) if ( m_pRun == NULL )
{ {
m_ErrorCode = TX_NORUN; m_ErrorCode = TX_NORUN;
return FALSE; return false;
} }
#if STACKMEM #if STACKMEM
@ -190,10 +190,10 @@ BOOL CBotProgram::Start(const char* name)
m_pStack->SetBotCall(this); // bases pour les routines m_pStack->SetBotCall(this); // bases pour les routines
return TRUE; // on est prêt pour un Run() return true; // on est prêt pour un Run()
} }
BOOL CBotProgram::GetPosition(const char* name, int& start, int& stop, CBotGet modestart, CBotGet modestop) bool CBotProgram::GetPosition(const char* name, int& start, int& stop, CBotGet modestart, CBotGet modestop)
{ {
CBotFunction* p = m_Prog; CBotFunction* p = m_Prog;
while (p != NULL) while (p != NULL)
@ -202,15 +202,15 @@ BOOL CBotProgram::GetPosition(const char* name, int& start, int& stop, CBotGet m
p = p->m_next; p = p->m_next;
} }
if ( p == NULL ) return FALSE; if ( p == NULL ) return false;
p->GetPosition(start, stop, modestart, modestop); p->GetPosition(start, stop, modestart, modestop);
return TRUE; return true;
} }
BOOL CBotProgram::Run(void* pUser, int timer) bool CBotProgram::Run(void* pUser, int timer)
{ {
BOOL ok; bool ok;
if (m_pStack == NULL || m_pRun == NULL) goto error; if (m_pStack == NULL || m_pRun == NULL) goto error;
@ -253,7 +253,7 @@ BOOL CBotProgram::Run(void* pUser, int timer)
delete m_pStack; delete m_pStack;
#endif #endif
m_pStack = NULL; m_pStack = NULL;
return TRUE; // exécution terminée !! return true; // exécution terminée !!
} }
if ( ok ) m_pRun = NULL; // plus de fonction en exécution if ( ok ) m_pRun = NULL; // plus de fonction en exécution
@ -261,7 +261,7 @@ BOOL CBotProgram::Run(void* pUser, int timer)
error: error:
m_ErrorCode = TX_NORUN; m_ErrorCode = TX_NORUN;
return TRUE; return true;
} }
void CBotProgram::Stop() void CBotProgram::Stop()
@ -277,14 +277,14 @@ void CBotProgram::Stop()
BOOL CBotProgram::GetRunPos(const char* &FunctionName, int &start, int &end) bool CBotProgram::GetRunPos(const char* &FunctionName, int &start, int &end)
{ {
FunctionName = NULL; FunctionName = NULL;
start = end = 0; start = end = 0;
if (m_pStack == NULL) return FALSE; if (m_pStack == NULL) return false;
m_pStack->GetRunPos(FunctionName, start, end); m_pStack->GetRunPos(FunctionName, start, end);
return TRUE; return true;
} }
CBotVar* CBotProgram::GivStackVars(const char* &FunctionName, int level) CBotVar* CBotProgram::GivStackVars(const char* &FunctionName, int level)
@ -321,7 +321,7 @@ long CBotProgram::GivIdent()
return m_Ident; return m_Ident;
} }
BOOL CBotProgram::GetError(int& code, int& start, int& end) bool CBotProgram::GetError(int& code, int& start, int& end)
{ {
code = m_ErrorCode; code = m_ErrorCode;
start = m_ErrorStart; start = m_ErrorStart;
@ -329,7 +329,7 @@ BOOL CBotProgram::GetError(int& code, int& start, int& end)
return code > 0; return code > 0;
} }
BOOL CBotProgram::GetError(int& code, int& start, int& end, CBotProgram* &pProg) bool CBotProgram::GetError(int& code, int& start, int& end, CBotProgram* &pProg)
{ {
code = m_ErrorCode; code = m_ErrorCode;
start = m_ErrorStart; start = m_ErrorStart;
@ -358,8 +358,8 @@ CBotFunction* CBotProgram::GivFunctions()
return m_Prog; return m_Prog;
} }
BOOL CBotProgram::AddFunction(const char* name, bool CBotProgram::AddFunction(const char* name,
BOOL rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
CBotTypResult rCompile (CBotVar* &pVar, void* pUser)) CBotTypResult rCompile (CBotVar* &pVar, void* pUser))
{ {
// mémorise les pointeurs aux deux fonctions // mémorise les pointeurs aux deux fonctions
@ -367,25 +367,25 @@ BOOL CBotProgram::AddFunction(const char* name,
} }
BOOL WriteWord(FILE* pf, WORD w) bool WriteWord(FILE* pf, unsigned short w)
{ {
size_t lg; size_t lg;
lg = fwrite(&w, sizeof( WORD ), 1, pf ); lg = fwrite(&w, sizeof( unsigned short ), 1, pf );
return (lg == 1); return (lg == 1);
} }
BOOL ReadWord(FILE* pf, WORD& w) bool ReadWord(FILE* pf, unsigned short& w)
{ {
size_t lg; size_t lg;
lg = fread(&w, sizeof( WORD ), 1, pf ); lg = fread(&w, sizeof( unsigned short ), 1, pf );
return (lg == 1); return (lg == 1);
} }
BOOL WriteFloat(FILE* pf, float w) bool WriteFloat(FILE* pf, float w)
{ {
size_t lg; size_t lg;
@ -394,7 +394,7 @@ BOOL WriteFloat(FILE* pf, float w)
return (lg == 1); return (lg == 1);
} }
BOOL ReadFloat(FILE* pf, float& w) bool ReadFloat(FILE* pf, float& w)
{ {
size_t lg; size_t lg;
@ -403,7 +403,7 @@ BOOL ReadFloat(FILE* pf, float& w)
return (lg == 1); return (lg == 1);
} }
BOOL WriteLong(FILE* pf, long w) bool WriteLong(FILE* pf, long w)
{ {
size_t lg; size_t lg;
@ -412,7 +412,7 @@ BOOL WriteLong(FILE* pf, long w)
return (lg == 1); return (lg == 1);
} }
BOOL ReadLong(FILE* pf, long& w) bool ReadLong(FILE* pf, long& w)
{ {
size_t lg; size_t lg;
@ -421,24 +421,24 @@ BOOL ReadLong(FILE* pf, long& w)
return (lg == 1); return (lg == 1);
} }
BOOL WriteString(FILE* pf, CBotString s) bool WriteString(FILE* pf, CBotString s)
{ {
size_t lg1, lg2; size_t lg1, lg2;
lg1 = s.GivLength(); lg1 = s.GivLength();
if (!WriteWord(pf, lg1)) return FALSE; if (!WriteWord(pf, lg1)) return false;
lg2 = fwrite(s, 1, lg1, pf ); lg2 = fwrite(s, 1, lg1, pf );
return (lg1 == lg2); return (lg1 == lg2);
} }
BOOL ReadString(FILE* pf, CBotString& s) bool ReadString(FILE* pf, CBotString& s)
{ {
WORD w; unsigned short w;
char buf[1000]; char buf[1000];
size_t lg1, lg2; size_t lg1, lg2;
if (!ReadWord(pf, w)) return FALSE; if (!ReadWord(pf, w)) return false;
lg1 = w; lg1 = w;
lg2 = fread(buf, 1, lg1, pf ); lg2 = fread(buf, 1, lg1, pf );
buf[lg2] = 0; buf[lg2] = 0;
@ -447,29 +447,29 @@ BOOL ReadString(FILE* pf, CBotString& s)
return (lg1 == lg2); return (lg1 == lg2);
} }
BOOL WriteType(FILE* pf, CBotTypResult type) bool WriteType(FILE* pf, CBotTypResult type)
{ {
int typ = type.GivType(); int typ = type.GivType();
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.GivClass();
if ( !WriteString(pf, p->GivName()) ) return FALSE; if ( !WriteString(pf, p->GivName()) ) 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.GivLimite()) ) return false;
if ( !WriteType(pf, type.GivTypElem()) ) return FALSE; if ( !WriteType(pf, type.GivTypElem()) ) return false;
} }
return TRUE; return true;
} }
BOOL ReadType(FILE* pf, CBotTypResult& type) bool ReadType(FILE* pf, CBotTypResult& type)
{ {
WORD w, ww; unsigned short w, ww;
if ( !ReadWord(pf, w) ) return FALSE; if ( !ReadWord(pf, w) ) return false;
type.SetType(w); type.SetType(w);
if ( type.Eq( CBotTypIntrinsic ) ) if ( type.Eq( CBotTypIntrinsic ) )
@ -480,7 +480,7 @@ BOOL ReadType(FILE* pf, CBotTypResult& type)
if ( type.Eq( CBotTypClass ) ) if ( type.Eq( CBotTypClass ) )
{ {
CBotString s; CBotString s;
if ( !ReadString(pf, s) ) return FALSE; if ( !ReadString(pf, s) ) return false;
type = CBotTypResult( w, s ); type = CBotTypResult( w, s );
} }
@ -488,54 +488,54 @@ BOOL ReadType(FILE* pf, CBotTypResult& type)
type.Eq( CBotTypArrayBody ) ) type.Eq( CBotTypArrayBody ) )
{ {
CBotTypResult r; CBotTypResult r;
if ( !ReadWord(pf, ww) ) return FALSE; if ( !ReadWord(pf, ww) ) return false;
if ( !ReadType(pf, r) ) return FALSE; if ( !ReadType(pf, r) ) return false;
type = CBotTypResult( w, r ); type = CBotTypResult( w, r );
type.SetLimite((short)ww); type.SetLimite((short)ww);
} }
return TRUE; return true;
} }
BOOL CBotProgram::DefineNum(const char* name, long val) bool CBotProgram::DefineNum(const char* name, long val)
{ {
return CBotToken::DefineNum(name, val); return CBotToken::DefineNum(name, val);
} }
BOOL CBotProgram::SaveState(FILE* pf) bool CBotProgram::SaveState(FILE* pf)
{ {
if (!WriteWord( pf, CBOTVERSION)) return FALSE; if (!WriteWord( pf, CBOTVERSION)) return false;
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->GivName() )) return false;
if (!m_pStack->SaveState(pf)) return FALSE; if (!m_pStack->SaveState(pf)) return false;
} }
else else
{ {
if (!WriteWord( pf, 0)) return FALSE; if (!WriteWord( pf, 0)) return false;
} }
return TRUE; return true;
} }
BOOL CBotProgram::RestoreState(FILE* pf) bool CBotProgram::RestoreState(FILE* pf)
{ {
WORD w; unsigned short w;
CBotString s; CBotString s;
Stop(); Stop();
if (!ReadWord( pf, w )) return FALSE; if (!ReadWord( pf, w )) return false;
if ( w != CBOTVERSION ) return FALSE; if ( w != CBOTVERSION ) return false;
if (!ReadWord( pf, w )) return FALSE; if (!ReadWord( pf, w )) return false;
if ( w == 0 ) return TRUE; if ( w == 0 ) return true;
if (!ReadString( pf, s )) return FALSE; if (!ReadString( pf, s )) return false;
Start(s); // point de reprise Start(s); // point de reprise
#if STACKMEM #if STACKMEM
@ -547,12 +547,12 @@ BOOL CBotProgram::RestoreState(FILE* pf)
// récupère la pile depuis l'enregistrement // récupère la pile depuis l'enregistrement
// utilise un pointeur NULL (m_pStack) mais c'est ok comme ça // utilise un pointeur NULL (m_pStack) mais c'est ok comme ça
if (!m_pStack->RestoreState(pf, m_pStack)) return FALSE; if (!m_pStack->RestoreState(pf, m_pStack)) return false;
m_pStack->SetBotCall(this); // bases pour les routines m_pStack->SetBotCall(this); // bases pour les routines
// rétabli certains états dans la pile selon la structure // rétabli certains états dans la pile selon la structure
m_pRun->RestoreState(NULL, m_pStack, m_pInstance); m_pRun->RestoreState(NULL, m_pStack, m_pInstance);
return TRUE; return true;
} }
int CBotProgram::GivVersion() int CBotProgram::GivVersion()
@ -566,7 +566,7 @@ int CBotProgram::GivVersion()
CBotCall* CBotCall::m_ListCalls = NULL; CBotCall* CBotCall::m_ListCalls = NULL;
CBotCall::CBotCall(const char* name, CBotCall::CBotCall(const char* name,
BOOL rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
CBotTypResult rCompile (CBotVar* &pVar, void* pUser)) CBotTypResult rCompile (CBotVar* &pVar, void* pUser))
{ {
m_name = name; m_name = name;
@ -587,8 +587,8 @@ void CBotCall::Free()
delete CBotCall::m_ListCalls; delete CBotCall::m_ListCalls;
} }
BOOL CBotCall::AddFunction(const char* name, bool CBotCall::AddFunction(const char* name,
BOOL rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
CBotTypResult rCompile (CBotVar* &pVar, void* pUser)) CBotTypResult rCompile (CBotVar* &pVar, void* pUser))
{ {
CBotCall* p = m_ListCalls; CBotCall* p = m_ListCalls;
@ -616,18 +616,18 @@ BOOL CBotCall::AddFunction(const char* name,
if (p) p->m_next = pp; if (p) p->m_next = pp;
else m_ListCalls = pp; else m_ListCalls = pp;
return TRUE; return true;
} }
// transforme le tableau de pointeurs aux variables // transforme le tableau de pointeurs aux variables
// en une liste de variables chaînées // en une liste de variables chaînées
CBotVar* MakeListVars(CBotVar** ppVars, BOOL bSetVal=FALSE) CBotVar* MakeListVars(CBotVar** ppVars, bool bSetVal=false)
{ {
int i = 0; int i = 0;
CBotVar* pVar = NULL; CBotVar* pVar = NULL;
while( TRUE ) while( true )
{ {
ppVars[i]; ppVars[i];
if ( ppVars[i] == NULL ) break; if ( ppVars[i] == NULL ) break;
@ -686,16 +686,16 @@ void CBotCall::SetPUser(void* pUser)
m_pUser = pUser; m_pUser = pUser;
} }
int CBotCall::CheckCall(const char* name) bool CBotCall::CheckCall(const char* name)
{ {
CBotCall* p = m_ListCalls; CBotCall* p = m_ListCalls;
while ( p != NULL ) while ( p != NULL )
{ {
if ( name == p->GivName() ) return TRUE; if ( name == p->GivName() ) return true;
p = p->m_next; p = p->m_next;
} }
return FALSE; return false;
} }
@ -746,7 +746,7 @@ fund:
#if !STACKRUN #if !STACKRUN
// fait la liste des paramètres selon le contenu de la pile (pStackVar) // fait la liste des paramètres selon le contenu de la pile (pStackVar)
CBotVar* pVar = MakeListVars(ppVar, TRUE); CBotVar* pVar = MakeListVars(ppVar, true);
CBotVar* pVarToDelete = pVar; CBotVar* pVarToDelete = pVar;
// crée une variable pour le résultat // crée une variable pour le résultat
@ -759,14 +759,14 @@ fund:
if ( pResult != pRes ) delete pRes; // si résultat différent rendu if ( pResult != pRes ) delete pRes; // si résultat différent rendu
delete pVarToDelete; delete pVarToDelete;
if (res == FALSE) if (res == false)
{ {
if (Exception!=0) if (Exception!=0)
{ {
pStack->SetError(Exception, token); pStack->SetError(Exception, token);
} }
delete pResult; delete pResult;
return FALSE; return false;
} }
pStack->SetVar(pResult); pStack->SetVar(pResult);
@ -775,16 +775,16 @@ fund:
pStack->SetError(TX_NORETVAL, token); pStack->SetError(TX_NORETVAL, token);
} }
nIdent = pt->m_nFuncIdent; nIdent = pt->m_nFuncIdent;
return TRUE; return true;
#else #else
CBotStack* pile = pStack->AddStackEOX(pt); CBotStack* pile = pStack->AddStackEOX(pt);
if ( pile == EOX ) return TRUE; if ( pile == EOX ) return true;
// fait la liste des paramètres selon le contenu de la pile (pStackVar) // fait la liste des paramètres selon le contenu de la pile (pStackVar)
CBotVar* pVar = MakeListVars(ppVar, TRUE); CBotVar* pVar = MakeListVars(ppVar, true);
CBotVar* pVarToDelete = pVar; CBotVar* pVarToDelete = pVar;
// crée une variable pour le résultat // crée une variable pour le résultat
@ -804,7 +804,7 @@ fund:
#if STACKRUN #if STACKRUN
BOOL CBotCall::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotStack* pStack) bool CBotCall::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotStack* pStack)
{ {
CBotCall* pt = m_ListCalls; CBotCall* pt = m_ListCalls;
@ -817,22 +817,22 @@ BOOL CBotCall::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBot
nIdent = pt->m_nFuncIdent; nIdent = pt->m_nFuncIdent;
CBotStack* pile = pStack->RestoreStackEOX(pt); CBotStack* pile = pStack->RestoreStackEOX(pt);
if ( pile == NULL ) return TRUE; if ( pile == NULL ) return true;
CBotStack* pile2 = pile->RestoreStack(); CBotStack* pile2 = pile->RestoreStack();
return TRUE; return true;
} }
pt = pt->m_next; pt = pt->m_next;
} }
} }
return FALSE; return false;
} }
BOOL CBotCall::Run(CBotStack* pStack) 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->GivVar();
CBotStack* pile2 = pile->AddStack(); CBotStack* pile2 = pile->AddStack();
@ -842,20 +842,20 @@ BOOL CBotCall::Run(CBotStack* pStack)
int Exception = 0; int Exception = 0;
int res = m_rExec(pVar, pResult, Exception, pStack->GivPUser()); int res = m_rExec(pVar, pResult, Exception, pStack->GivPUser());
if (res == FALSE) if (res == false)
{ {
if (Exception!=0) if (Exception!=0)
{ {
pStack->SetError(Exception); pStack->SetError(Exception);
} }
if ( pResult != pRes ) delete pResult; // si résultat différent rendu if ( pResult != pRes ) delete pResult; // si résultat différent rendu
return FALSE; return false;
} }
if ( pResult != NULL ) pStack->SetCopyVar( pResult ); if ( pResult != NULL ) pStack->SetCopyVar( pResult );
if ( pResult != pRes ) delete pResult; // si résultat différent rendu if ( pResult != pRes ) delete pResult; // si résultat différent rendu
return TRUE; return true;
} }
#endif #endif
@ -863,7 +863,7 @@ BOOL CBotCall::Run(CBotStack* pStack)
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
CBotCallMethode::CBotCallMethode(const char* name, CBotCallMethode::CBotCallMethode(const char* name,
BOOL rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception),
CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar)) CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar))
{ {
m_name = name; m_name = name;
@ -893,7 +893,7 @@ CBotTypResult CBotCallMethode::CompileCall(const char* name, CBotVar* pThis,
{ {
if ( pt->m_name == name ) if ( pt->m_name == name )
{ {
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.GivType();
@ -942,7 +942,7 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
{ {
// fait la liste des paramètres selon le contenu de la pile (pStackVar) // fait la liste des paramètres selon le contenu de la pile (pStackVar)
CBotVar* pVar = MakeListVars(ppVars, TRUE); CBotVar* pVar = MakeListVars(ppVars, true);
CBotVar* pVarToDelete = pVar; CBotVar* pVarToDelete = pVar;
// puis appelle la routine externe au module // puis appelle la routine externe au module
@ -951,7 +951,7 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
int res = pt->m_rExec(pThis, pVar, pResult, Exception); int res = pt->m_rExec(pThis, pVar, pResult, Exception);
pStack->SetVar(pResult); pStack->SetVar(pResult);
if (res == FALSE) if (res == false)
{ {
if (Exception!=0) if (Exception!=0)
{ {
@ -959,10 +959,10 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
pStack->SetError(Exception, pToken); pStack->SetError(Exception, pToken);
} }
delete pVarToDelete; delete pVarToDelete;
return FALSE; return false;
} }
delete pVarToDelete; delete pVarToDelete;
return TRUE; return true;
} }
pt = pt->m_next; pt = pt->m_next;
} }
@ -975,14 +975,14 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
{ {
// fait la liste des paramètres selon le contenu de la pile (pStackVar) // fait la liste des paramètres selon le contenu de la pile (pStackVar)
CBotVar* pVar = MakeListVars(ppVars, TRUE); CBotVar* pVar = MakeListVars(ppVars, true);
CBotVar* pVarToDelete = pVar; CBotVar* pVarToDelete = pVar;
int Exception = 0; int Exception = 0;
int res = pt->m_rExec(pThis, pVar, pResult, Exception); int res = pt->m_rExec(pThis, pVar, pResult, Exception);
pStack->SetVar(pResult); pStack->SetVar(pResult);
if (res == FALSE) if (res == false)
{ {
if (Exception!=0) if (Exception!=0)
{ {
@ -990,11 +990,11 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
pStack->SetError(Exception, pToken); pStack->SetError(Exception, pToken);
} }
delete pVarToDelete; delete pVarToDelete;
return FALSE; return false;
} }
delete pVarToDelete; delete pVarToDelete;
nIdent = pt->m_nFuncIdent; nIdent = pt->m_nFuncIdent;
return TRUE; return true;
} }
pt = pt->m_next; pt = pt->m_next;
} }
@ -1002,7 +1002,7 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
return -1; return -1;
} }
BOOL rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) bool rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
{ {
if ( pVar == NULL ) return TX_LOWPARAM; if ( pVar == NULL ) return TX_LOWPARAM;
@ -1016,7 +1016,7 @@ BOOL rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
} }
pResult->SetValInt(i); pResult->SetValInt(i);
return TRUE; return true;
} }
CBotTypResult cSizeOf( CBotVar* &pVar, void* pUser ) CBotTypResult cSizeOf( CBotVar* &pVar, void* pUser )
@ -1030,11 +1030,11 @@ CBotTypResult cSizeOf( CBotVar* &pVar, void* pUser )
CBotString CBotProgram::m_DebugVarStr = ""; CBotString CBotProgram::m_DebugVarStr = "";
BOOL rCBotDebug( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) bool rCBotDebug( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
{ {
pResult->SetValString( CBotProgram::m_DebugVarStr ); pResult->SetValString( CBotProgram::m_DebugVarStr );
return TRUE; return true;
} }
CBotTypResult cCBotDebug( CBotVar* &pVar, void* pUser ) CBotTypResult cCBotDebug( CBotVar* &pVar, void* pUser )
@ -1103,7 +1103,8 @@ void CBotProgram::Init()
// une fonction juste pour les debug divers // une fonction juste pour les debug divers
CBotProgram::AddFunction("CBOTDEBUGDD", rCBotDebug, cCBotDebug); CBotProgram::AddFunction("CBOTDEBUGDD", rCBotDebug, cCBotDebug);
DeleteFile("CbotDebug.txt"); //TODO implement this deletion
// DeleteFile("CbotDebug.txt");
} }

File diff suppressed because it is too large Load Diff

View File

@ -13,51 +13,145 @@
// * // *
// * You should have received a copy of the GNU General Public License // * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.///////////////////////////////////////////////////// // * along with this program. If not, see http://www.gnu.org/licenses/./////////////////////////////////////////////////////
// gestion de chaine
// basé sur le CString de MFC //strings management
// mais moins complet
#include "CBot.h" #include "CBot.h"
#include <string.h> #include <cstdlib>
#include <cstring>
HINSTANCE CBotString::m_hInstance = (HINSTANCE)LoadLibrary("libCbot.dll"); // comment le récupérer autrement ?? #include <algorithm>
//Map is filled with id-string pars that are needed for CBot language parsing
const std::map<EID, char *> CBotString::s_keywordString =
{
{ID_IF, "if"},
{ID_ELSE, "else"},
{ID_WHILE, "while"},
{ID_DO, "do"},
{ID_FOR, "for"},
{ID_BREAK, "break"},
{ID_CONTINUE, "continue"},
{ID_SWITCH, "switch"},
{ID_CASE, "case"},
{ID_DEFAULT, "default"},
{ID_TRY, "try"},
{ID_THROW, "throw"},
{ID_CATCH, "catch"},
{ID_FINALLY, "finally"},
{ID_TXT_AND, "and"},
{ID_TXT_OR, "or"},
{ID_TXT_NOT, "not"},
{ID_RETURN, "return"},
{ID_CLASS, "class"},
{ID_EXTENDS, "extends"},
{ID_SYNCHO, "synchronized"},
{ID_NEW, "new"},
{ID_PUBLIC, "public"},
{ID_EXTERN, "extern"},
{ID_FINAL, "final"},
{ID_STATIC, "static"},
{ID_PROTECTED, "protected"},
{ID_PRIVATE, "private"},
{ID_REPEAT, "repeat"},
{ID_DEBUGDD, "STARTDEBUGDD"},
{ID_INT, "int"},
{ID_FLOAT, "float"},
{ID_BOOLEAN, "boolean"},
{ID_STRING, "string"},
{ID_VOID, "void"},
{ID_BOOL, "bool"},
{ID_TRUE, "true"},
{ID_FALSE, "false"},
{ID_NULL, "null"},
{ID_NAN, "nan"},
{ID_OPENPAR, "("},
{ID_CLOSEPAR, ")"},
{ID_OPBLK, "{"},
{ID_CLBLK, "}"},
{ID_SEP, "},"},
{ID_COMMA, ","},
{ID_DOTS, ":"},
{ID_DOT, "."},
{ID_OPBRK, "["},
{ID_CLBRK, "]"},
{ID_DBLDOTS, "::"},
{ID_LOGIC, "?"},
{ID_ADD, "+"},
{ID_SUB, "-"},
{ID_MUL, "*"},
{ID_DIV, "/"},
{ID_ASS, "="},
{ID_ASSADD, "+="},
{ID_ASSSUB, "-="},
{ID_ASSMUL, "*="},
{ID_ASSDIV, "/="},
{ID_ASSOR, "|="},
{ID_ASSAND, "&="},
{ID_ASSXOR, "^="},
{ID_ASSSL, "<<="},
{ID_ASSSR, ">>>="},
{ID_ASSASR, ">>="},
{ID_SL, "<<"},
{ID_SR, ">>"},
{ID_ASR, ">>"},
{ID_INC, "++"},
{ID_DEC, "--"},
{ID_LO, "<"},
{ID_HI, ">"},
{ID_LS, "<<"},
{ID_HS, ">="},
{ID_EQ, "=="},
{ID_NE, "!="},
{ID_AND, "&"},
{ID_XOR, "^"},
{ID_OR, "|"},
{ID_LOG_AND, "&&"},
{ID_LOG_OR, "||"},
{ID_LOG_NOT, "!"},
{ID_NOT, "~"},
{ID_MODULO, "%"},
{ID_POWER, "**"},
{ID_ASSMODULO, "%="},
{ID_SUPER, "super"},
{TX_UNDEF, "undefined"},
{TX_NAN, "not a number"}
};
CBotString::CBotString() CBotString::CBotString()
{ {
m_ptr = NULL; // chaine vide m_ptr = NULL;
m_lg = 0; m_lg = 0;
} }
CBotString::~CBotString() CBotString::~CBotString()
{ {
if (m_ptr != NULL) free(m_ptr); free(m_ptr); //we can call free on null pointer as it's save
} }
CBotString::CBotString(const char* p) CBotString::CBotString(const char* p)
{ {
m_lg = lstrlen( p ); m_lg = strlen(p);
m_ptr = NULL; m_ptr = NULL;
if (m_lg>0) if (m_lg>0)
{ {
m_ptr = (char*)malloc(m_lg+1); m_ptr = (char*)malloc(m_lg+1);
lstrcpy(m_ptr, p); strcpy(m_ptr, p);
} }
} }
CBotString::CBotString(const CBotString& srcString) CBotString::CBotString(const CBotString& srcString)
{ {
m_lg = srcString.m_lg; m_lg = srcString.m_lg;
m_ptr = NULL; m_ptr = NULL;
if (m_lg>0) if (m_lg>0)
{ {
m_ptr = (char*)malloc(m_lg+1); m_ptr = (char*)malloc(m_lg+1);
lstrcpy(m_ptr, srcString.m_ptr); strcpy(m_ptr, srcString.m_ptr);
} }
} }
@ -65,539 +159,533 @@ CBotString::CBotString(const CBotString& srcString)
int CBotString::GivLength() int CBotString::GivLength()
{ {
if ( m_ptr == NULL ) return 0; if (m_ptr == NULL) return 0;
return lstrlen( m_ptr ); return strlen( m_ptr );
} }
CBotString CBotString::Left(int nCount) const CBotString CBotString::Left(int nCount) const
{ {
char chaine[2000]; char chain[2000];
int i; size_t i;
for (i = 0; i < m_lg && i < nCount && i < 1999; i++) for (i = 0; i < m_lg && i < nCount && i < 1999; ++i)
{ {
chaine[i] = m_ptr[i]; chain[i] = m_ptr[i];
} }
chaine[i] = 0 ; chain[i] = 0 ;
return CBotString( chaine ); return CBotString(chain);
} }
CBotString CBotString::Right(int nCount) const CBotString CBotString::Right(int nCount) const
{ {
char chaine[2000]; char chain[2000];
int i = m_lg - nCount; int i = m_lg - nCount;
if ( i < 0 ) i = 0; if ( i < 0 ) i = 0;
int j; size_t j;
for ( j = 0 ; i < m_lg && i < 1999; i++) for (size_t j = 0 ; i < m_lg && i < 1999; ++i)
{ {
chaine[j++] = m_ptr[i]; chain[j++] = m_ptr[i];
} }
chaine[j] = 0 ; chain[j] = 0 ;
return CBotString( chaine ); return CBotString(chain);
} }
CBotString CBotString::Mid(int nFirst, int nCount) const CBotString CBotString::Mid(int nFirst, int nCount) const
{ {
char chaine[2000]; char chain[2000];
int i; size_t i;
for (i = nFirst; i < m_lg && i < 1999 && i <= nFirst + nCount; ++i)
{
chain[i] = m_ptr[i];
}
chain[i] = 0 ;
for ( i = nFirst; i < m_lg && i < 1999 && i <= nFirst + nCount; i++) return CBotString(chain);
{
chaine[i] = m_ptr[i];
}
chaine[i] = 0 ;
return CBotString( chaine );
} }
CBotString CBotString::Mid(int nFirst) const CBotString CBotString::Mid(int nFirst) const
{ {
char chaine[2000]; char chain[2000];
int i; size_t i;
for (i = nFirst; i < m_lg && i < 1999 ; ++i)
{
chain[i] = m_ptr[i];
}
chain[i] = 0 ;
for ( i = nFirst; i < m_lg && i < 1999 ; i++) return CBotString(chain);
{
chaine[i] = m_ptr[i];
}
chaine[i] = 0 ;
return CBotString( chaine );
} }
int CBotString::Find(const char c) int CBotString::Find(const char c)
{ {
int i; for (size_t i = 0; i < m_lg; ++i)
for (i = 0; i < m_lg; i++) {
{ if (m_ptr[i] == c) return i;
if (m_ptr[i] == c) return i; }
} return -1;
return -1;
} }
int CBotString::Find(LPCTSTR lpsz) int CBotString::Find(const char * lpsz)
{ {
int i, j; int l = strlen(lpsz);
int l = lstrlen(lpsz);
for (i = 0; i <= m_lg-l; i++) for (size_t i = 0; i <= m_lg-l; ++i)
{ {
for (j = 0; j < l; j++) for (size_t j = 0; j < l; ++j)
{ {
if (m_ptr[i+j] != lpsz[j]) goto bad; if (m_ptr[i+j] != lpsz[j]) goto bad;
} }
return i; return i;
bad:; bad:;
} }
return -1; return -1;
} }
int CBotString::ReverseFind(const char c) int CBotString::ReverseFind(const char c)
{ {
int i; int i;
for (i = m_lg-1; i >= 0; i--) for (i = m_lg-1; i >= 0; --i)
{ {
if (m_ptr[i] == c) return i; if (m_ptr[i] == c) return i;
} }
return -1; return -1;
} }
int CBotString::ReverseFind(LPCTSTR lpsz) int CBotString::ReverseFind(const char * lpsz)
{ {
int i, j; int i, j;
int l = lstrlen(lpsz); int l = strlen(lpsz);
for (i = m_lg-l; i >= 0; i--) for (i = m_lg-l; i >= 0; --i)
{ {
for (j = 0; j < l; j++) for (j = 0; j < l; ++j)
{ {
if (m_ptr[i+j] != lpsz[j]) goto bad; if (m_ptr[i+j] != lpsz[j]) goto bad;
} }
return i; return i;
bad:; bad:;
} }
return -1; return -1;
} }
CBotString CBotString::Mid(int start, int lg) CBotString CBotString::Mid(int start, int lg)
{ {
CBotString res; CBotString res;
if (start >= m_lg) return res; if (start >= m_lg) return res;
if ( lg < 0 ) lg = m_lg - start; if ( lg < 0 ) lg = m_lg - start;
char* p = (char*)malloc(m_lg+1); char* p = (char*)malloc(m_lg+1);
lstrcpy(p, m_ptr+start); strcpy(p, m_ptr+start);
p[lg] = 0; p[lg] = 0;
res = p; res = p;
free(p); free(p);
return res; return res;
} }
void CBotString::MakeUpper() void CBotString::MakeUpper()
{ {
int i; for (size_t i = 0; i < m_lg && i < 1999 ; ++i)
{
for ( i = 0; i < m_lg && i < 1999 ; i++) char c = m_ptr[i];
{ if ( c >= 'a' && c <= 'z' ) m_ptr[i] = c - 'a' + 'A';
char c = m_ptr[i]; }
if ( c >= 'a' && c <= 'z' ) m_ptr[i] = c - 'a' + 'A';
}
} }
void CBotString::MakeLower() void CBotString::MakeLower()
{ {
int i; for (size_t i = 0; i < m_lg && i < 1999 ; ++i)
{
for ( i = 0; i < m_lg && i < 1999 ; i++) char c = m_ptr[i];
{ if ( c >= 'A' && c <= 'Z' ) m_ptr[i] = c - 'A' + 'a';
char c = m_ptr[i]; }
if ( c >= 'A' && c <= 'Z' ) m_ptr[i] = c - 'A' + 'a';
}
} }
bool CBotString::LoadString(unsigned int id)
#define MAXSTRING 256
BOOL CBotString::LoadString(UINT id)
{ {
char buffer[MAXSTRING]; const char * str = NULL;
str = MapIdToString((EID)id);
if (m_ptr != NULL) free(m_ptr);
m_lg = ::LoadString( m_hInstance, id, buffer, MAXSTRING ); m_lg = strlen(str);
m_ptr = NULL;
if (m_ptr != NULL) free(m_ptr); if (m_lg > 0)
{
m_ptr = NULL; m_ptr = (char*)malloc(m_lg+1);
if (m_lg > 0) strcpy(m_ptr, str);
{ return true;
m_ptr = (char*)malloc(m_lg+1); }
lstrcpy(m_ptr, buffer); return false;
return TRUE;
}
return FALSE;
} }
const CBotString& CBotString::operator=(const CBotString& stringSrc) const CBotString& CBotString::operator=(const CBotString& stringSrc)
{ {
if (m_ptr != NULL) free(m_ptr); free(m_ptr);
m_ptr = NULL;
m_lg = stringSrc.m_lg; m_lg = stringSrc.m_lg;
m_ptr = NULL;
if (m_lg > 0) if (m_lg > 0)
{ {
m_ptr = (char*)malloc(m_lg+1); m_ptr = (char*)malloc(m_lg+1);
lstrcpy(m_ptr, stringSrc.m_ptr); strcpy(m_ptr, stringSrc.m_ptr);
} }
return *this; return *this;
} }
CBotString operator+(const CBotString& string, LPCTSTR lpsz) CBotString operator+(const CBotString& string, const char * lpsz)
{ {
CBotString s ( string ); CBotString s(string);
s += lpsz; s += lpsz;
return s; return s;
} }
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 = (char*)malloc(m_lg+stringSrc.m_lg+1);
lstrcpy(p, m_ptr); strcpy(p, m_ptr);
char* pp = p + m_lg; char* pp = p + m_lg;
lstrcpy(pp, stringSrc.m_ptr); strcpy(pp, stringSrc.m_ptr);
if (m_ptr != NULL) free(m_ptr); free(m_ptr);
m_ptr = p; m_ptr = p;
m_lg += stringSrc.m_lg; m_lg += stringSrc.m_lg;
return *this; return *this;
} }
const CBotString& CBotString::operator=(const char ch) const CBotString& CBotString::operator=(const char ch)
{ {
if (m_ptr != NULL) free(m_ptr); free(m_ptr);
m_lg = 1; m_lg = 1;
m_ptr = (char*)malloc(2); m_ptr = (char*)malloc(2);
m_ptr[0] = ch; m_ptr[0] = ch;
m_ptr[1] = 0; m_ptr[1] = 0;
return *this; return *this;
} }
const CBotString& CBotString::operator=(const char* pString) const CBotString& CBotString::operator=(const char* pString)
{ {
if (m_ptr != NULL) free(m_ptr); free(m_ptr);
m_ptr = NULL; m_ptr = NULL;
if ( pString != NULL ) if (pString != NULL)
{ {
m_lg = lstrlen(pString); m_lg = strlen(pString);
if (m_lg != 0) if (m_lg != 0)
{ {
m_ptr = (char*)malloc(m_lg+1); m_ptr = (char*)malloc(m_lg+1);
lstrcpy(m_ptr, pString); strcpy(m_ptr, pString);
} }
} }
return *this; return *this;
} }
const CBotString& CBotString::operator+=(const char ch) const CBotString& CBotString::operator+=(const char ch)
{ {
char* p = (char*)malloc(m_lg+2); char* p = (char*)malloc(m_lg+2);
if (m_ptr!=NULL) lstrcpy(p, m_ptr); if (m_ptr!=NULL) strcpy(p, m_ptr);
p[m_lg++] = ch; p[m_lg++] = ch;
p[m_lg] = 0; p[m_lg] = 0;
if (m_ptr != NULL) free(m_ptr); free(m_ptr);
m_ptr = p; m_ptr = p;
return *this; return *this;
} }
const CBotString& CBotString::operator+=(const CBotString& str) const CBotString& CBotString::operator+=(const CBotString& str)
{ {
char* p = (char*)malloc(m_lg+str.m_lg+1); char* p = (char*)malloc(m_lg+str.m_lg+1);
lstrcpy(p, m_ptr); strcpy(p, m_ptr);
char* pp = p + m_lg; char* pp = p + m_lg;
lstrcpy(pp, str.m_ptr); strcpy(pp, str.m_ptr);
m_lg = m_lg + str.m_lg; m_lg = m_lg + str.m_lg;
if (m_ptr != NULL) free(m_ptr); free(m_ptr);
m_ptr = p; m_ptr = p;
return *this; return *this;
} }
BOOL CBotString::operator==(const CBotString& str) bool CBotString::operator==(const CBotString& str)
{ {
return Compare(str) == 0; return Compare(str) == 0;
} }
BOOL CBotString::operator==(const char* p) bool CBotString::operator==(const char* p)
{ {
return Compare(p) == 0; return Compare(p) == 0;
} }
BOOL CBotString::operator!=(const CBotString& str) bool CBotString::operator!=(const CBotString& str)
{ {
return Compare(str) != 0; return Compare(str) != 0;
} }
BOOL CBotString::operator!=(const char* p) bool CBotString::operator!=(const char* p)
{ {
return Compare(p) != 0; return Compare(p) != 0;
} }
BOOL CBotString::operator>(const CBotString& str) bool CBotString::operator>(const CBotString& str)
{ {
return Compare(str) > 0; return Compare(str) > 0;
} }
BOOL CBotString::operator>(const char* p) bool CBotString::operator>(const char* p)
{ {
return Compare(p) > 0; return Compare(p) > 0;
} }
BOOL CBotString::operator>=(const CBotString& str) bool CBotString::operator>=(const CBotString& str)
{ {
return Compare(str) >= 0; return Compare(str) >= 0;
} }
BOOL CBotString::operator>=(const char* p) bool CBotString::operator>=(const char* p)
{ {
return Compare(p) >= 0; return Compare(p) >= 0;
} }
BOOL CBotString::operator<(const CBotString& str) bool CBotString::operator<(const CBotString& str)
{ {
return Compare(str) < 0; return Compare(str) < 0;
} }
BOOL CBotString::operator<(const char* p) bool CBotString::operator<(const char* p)
{ {
return Compare(p) < 0; return Compare(p) < 0;
} }
BOOL CBotString::operator<=(const CBotString& str) bool CBotString::operator<=(const CBotString& str)
{ {
return Compare(str) <= 0; return Compare(str) <= 0;
} }
BOOL CBotString::operator<=(const char* p) bool CBotString::operator<=(const char* p)
{ {
return Compare(p) <= 0; return Compare(p) <= 0;
} }
BOOL CBotString::IsEmpty() const bool CBotString::IsEmpty() const
{ {
return (m_lg == 0); return (m_lg == 0);
} }
void CBotString::Empty() void CBotString::Empty()
{ {
if (m_ptr != NULL) free(m_ptr); free(m_ptr);
m_ptr = NULL; m_ptr = NULL;
m_lg = 0; m_lg = 0;
} }
static char nilstring[] = {0}; static char emptyString[] = {0};
CBotString::operator LPCTSTR() const CBotString::operator const char * () const
{ {
if (this == NULL || m_ptr == NULL) return nilstring; if (this == NULL || m_ptr == NULL) return emptyString;
return m_ptr; return m_ptr;
} }
int CBotString::Compare(LPCTSTR lpsz) const int CBotString::Compare(const char * lpsz) const
{ {
char* p = m_ptr; char* p = m_ptr;
if (lpsz == NULL) lpsz = nilstring; if (lpsz == NULL) lpsz = emptyString;
if (m_ptr == NULL) p = nilstring; if (m_ptr == NULL) p = emptyString;
return strcmp(p, lpsz); // wcscmp return strcmp(p, lpsz); // wcscmp
} }
const char * CBotString::MapIdToString(EID id)
{
if (s_keywordString.find(id) != s_keywordString.end())
{
return s_keywordString.at(id);
}
else
{
return emptyString;
}
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// tableaux de chaines // arrays of strings
CBotStringArray::CBotStringArray() CBotStringArray::CBotStringArray()
{ {
m_pData = NULL; m_pData = NULL;
m_nSize = m_nMaxSize = 0; m_nSize = m_nMaxSize = 0;
} }
CBotStringArray::~CBotStringArray() CBotStringArray::~CBotStringArray()
{ {
SetSize(0); // détruit les données ! SetSize(0); // destroys data !
} }
int CBotStringArray::GivSize() int CBotStringArray::GivSize()
{ {
return m_nSize; return m_nSize;
} }
void CBotStringArray::Add(const CBotString& str) void CBotStringArray::Add(const CBotString& str)
{ {
SetSize(m_nSize+1); SetSize(m_nSize+1);
m_pData[m_nSize-1] = str; m_pData[m_nSize-1] = str;
} }
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
// routines utilitaires // utility routines
static inline void ConstructElement(CBotString* pNewData) static inline void ConstructElement(CBotString* pNewData)
{ {
memset(pNewData, 0, sizeof(CBotString)); memset(pNewData, 0, sizeof(CBotString));
} }
static inline void DestructElement(CBotString* pOldData) static inline void DestructElement(CBotString* pOldData)
{ {
pOldData->~CBotString(); pOldData->~CBotString();
} }
static inline void CopyElement(CBotString* pSrc, CBotString* pDest) static inline void CopyElement(CBotString* pSrc, CBotString* pDest)
{ {
*pSrc = *pDest; *pSrc = *pDest;
} }
static void ConstructElements(CBotString* pNewData, int nCount) static void ConstructElements(CBotString* pNewData, int nCount)
{ {
while (nCount--) while (nCount--)
{ {
ConstructElement(pNewData); ConstructElement(pNewData);
pNewData++; pNewData++;
} }
} }
static void DestructElements(CBotString* pOldData, int nCount) static void DestructElements(CBotString* pOldData, int nCount)
{ {
while (nCount--) while (nCount--)
{ {
DestructElement(pOldData); DestructElement(pOldData);
pOldData++; pOldData++;
} }
} }
static void CopyElements(CBotString* pDest, CBotString* pSrc, int nCount) static void CopyElements(CBotString* pDest, CBotString* pSrc, int nCount)
{ {
while (nCount--) while (nCount--)
{ {
*pDest = *pSrc; *pDest = *pSrc;
++pDest; ++pDest;
++pSrc; ++pSrc;
} }
} }
// sélect la taille du tableau // set the array size
void CBotStringArray::SetSize(int nNewSize) void CBotStringArray::SetSize(int nNewSize)
{ {
if (nNewSize == 0) if (nNewSize == 0)
{ {
// shrink to nothing // shrink to nothing
DestructElements(m_pData, m_nSize); DestructElements(m_pData, m_nSize);
delete[] (BYTE*)m_pData; delete[] (unsigned char *)m_pData;
m_pData = NULL; m_pData = NULL;
m_nSize = m_nMaxSize = 0; m_nSize = m_nMaxSize = 0;
} }
else if (m_pData == NULL) else if (m_pData == NULL)
{ {
// create one with exact size // create one with exact size
m_pData = (CBotString*) new BYTE[nNewSize * sizeof(CBotString)]; m_pData = (CBotString*) new unsigned char[nNewSize * sizeof(CBotString)];
ConstructElements(m_pData, nNewSize); ConstructElements(m_pData, nNewSize);
m_nSize = m_nMaxSize = nNewSize; m_nSize = m_nMaxSize = nNewSize;
} }
else if (nNewSize <= m_nMaxSize) else if (nNewSize <= m_nMaxSize)
{ {
// it fits // it fits
if (nNewSize > m_nSize) if (nNewSize > m_nSize)
{ {
// initialize the new elements // initialize the new elements
ConstructElements(&m_pData[m_nSize], nNewSize-m_nSize); ConstructElements(&m_pData[m_nSize], nNewSize-m_nSize);
} }
else if (m_nSize > nNewSize) // destroy the old elements else if (m_nSize > nNewSize) // destroy the old elements
DestructElements(&m_pData[nNewSize], m_nSize-nNewSize); DestructElements(&m_pData[nNewSize], m_nSize-nNewSize);
m_nSize = nNewSize; m_nSize = nNewSize;
} }
else else
{ {
// otherwise, grow array // otherwise, grow array
int nGrowBy; int nGrowBy;
{ {
// heuristically determine growth when nGrowBy == 0 // heuristically determine growth when nGrowBy == 0
// (this avoids heap fragmentation in many situations) // (this avoids heap fragmentation in many situations)
nGrowBy = min(1024, max(4, m_nSize / 8)); nGrowBy = std::min(1024, std::max(4, m_nSize / 8));
} }
int nNewMax; int nNewMax;
if (nNewSize < m_nMaxSize + nGrowBy) if (nNewSize < m_nMaxSize + nGrowBy)
nNewMax = m_nMaxSize + nGrowBy; // granularity nNewMax = m_nMaxSize + nGrowBy; // granularity
else else
nNewMax = nNewSize; // no slush nNewMax = nNewSize; // no slush
CBotString* pNewData = (CBotString*) new BYTE[nNewMax * sizeof(CBotString)]; CBotString* pNewData = (CBotString*) new unsigned char[nNewMax * sizeof(CBotString)];
// copy new data from old // copy new data from old
memcpy(pNewData, m_pData, m_nSize * sizeof(CBotString)); memcpy(pNewData, m_pData, m_nSize * sizeof(CBotString));
// construct remaining elements // construct remaining elements
ConstructElements(&pNewData[m_nSize], nNewSize-m_nSize); ConstructElements(&pNewData[m_nSize], nNewSize-m_nSize);
// Ret rid of old stuff (note: no destructors called) // Get rid of old stuff (note: no destructors called)
delete[] (BYTE*)m_pData; delete[] (unsigned char *)m_pData;
m_pData = pNewData; m_pData = pNewData;
m_nSize = nNewSize; m_nSize = nNewSize;
m_nMaxSize = nNewMax; m_nMaxSize = nNewMax;
} }
} }
CBotString& CBotStringArray::operator[](int nIndex) CBotString& CBotStringArray::operator[](int nIndex)
{ {
return ElementAt(nIndex); return ElementAt(nIndex);
} }
CBotString& CBotStringArray::ElementAt(int nIndex) CBotString& CBotStringArray::ElementAt(int nIndex)
{ {
return m_pData[nIndex]; return m_pData[nIndex];
} }

View File

@ -22,6 +22,7 @@
#include "CBot.h" #include "CBot.h"
#include <cstdarg>
CBotStringArray CBotToken::m_ListKeyWords; CBotStringArray CBotToken::m_ListKeyWords;
int CBotToken::m_ListIdKeyWords[200]; int CBotToken::m_ListIdKeyWords[200];
@ -188,27 +189,27 @@ void CBotToken::SetPos(int start, int end)
m_end = end; m_end = end;
} }
BOOL CharInList(const char c, const char* list) bool CharInList(const char c, const char* list)
{ {
int i = 0; int i = 0;
while (TRUE) while (true)
{ {
if (c == list[i++]) return TRUE; if (c == list[i++]) return true;
if (list[i] == 0) return FALSE; if (list[i] == 0) return false;
} }
} }
BOOL Char2InList(const char c, const char cc, const char* list) bool Char2InList(const char c, const char cc, const char* list)
{ {
int i = 0; int i = 0;
while (TRUE) while (true)
{ {
if (c == list[i++] && if (c == list[i++] &&
cc == list[i++]) return TRUE; cc == list[i++]) return true;
if (list[i] == 0) return FALSE; if (list[i] == 0) return false;
} }
} }
@ -224,12 +225,12 @@ static char* nch = "\"\r\n\t"; // refus
// cherche le prochain token dans une phrase // cherche le prochain token dans une phrase
// ne doit pas commencer par des séparateurs // ne doit pas commencer par des séparateurs
// qui sont pris avec le token précédent // qui sont pris avec le token précédent
CBotToken* CBotToken::NextToken(char* &program, int& error, BOOL first) CBotToken* CBotToken::NextToken(char* &program, int& error, bool first)
{ {
CBotString mot; // le mot trouvé CBotString mot; // le mot trouvé
CBotString sep; // les séparateurs qui le suivent CBotString sep; // les séparateurs qui le suivent
char c; char c;
BOOL stop = first; bool stop = first;
if (*program == 0) return NULL; if (*program == 0) return NULL;
@ -262,14 +263,14 @@ CBotToken* CBotToken::NextToken(char* &program, int& error, BOOL first)
mot += c; // chaîne complète mot += c; // chaîne complète
c = *(program++); // prochain caractère c = *(program++); // prochain caractère
} }
stop = TRUE; stop = true;
} }
// cas particulier pour les nombres // cas particulier pour les nombres
if ( CharInList(mot[0], num )) if ( CharInList(mot[0], num ))
{ {
BOOL bdot = FALSE; // trouvé un point ? bool bdot = false; // trouvé un point ?
BOOL bexp = FALSE; // trouvé un exposant ? bool bexp = false; // trouvé un exposant ?
char* liste = num; char* liste = num;
if (mot[0] == '0' && c == 'x') // valeur hexadécimale ? if (mot[0] == '0' && c == 'x') // valeur hexadécimale ?
@ -286,10 +287,10 @@ cc: mot += c;
} }
if ( liste == num ) // pas pour les exadécimaux if ( liste == num ) // pas pour les exadécimaux
{ {
if ( !bdot && c == '.' ) { bdot = TRUE; goto cc; } if ( !bdot && c == '.' ) { bdot = true; goto cc; }
if ( !bexp && ( c == 'e' || c == 'E' ) ) if ( !bexp && ( c == 'e' || c == 'E' ) )
{ {
bexp = TRUE; bexp = true;
mot += c; mot += c;
c = *(program++); // prochain caractère c = *(program++); // prochain caractère
if ( c == '-' || if ( c == '-' ||
@ -298,7 +299,7 @@ cc: mot += c;
} }
} }
stop = TRUE; stop = true;
} }
if (CharInList(mot[0], sep3)) // un séparateur opérationnel ? if (CharInList(mot[0], sep3)) // un séparateur opérationnel ?
@ -310,13 +311,13 @@ cc: mot += c;
c = *(program++); // prochain caractère c = *(program++); // prochain caractère
} }
stop = TRUE; stop = true;
} }
} }
while (TRUE) while (true)
{ {
if (stop || c == 0 || CharInList(c, sep1)) if (stop || c == 0 || CharInList(c, sep1))
{ {
@ -381,7 +382,7 @@ CBotToken* CBotToken::CompileTokens(const char* program, int& error)
int pos = 0; int pos = 0;
error = 0; error = 0;
prv = tokenbase = NextToken(p, error, TRUE); prv = tokenbase = NextToken(p, error, true);
if (tokenbase == NULL) return NULL; if (tokenbase == NULL) return NULL;
@ -443,7 +444,7 @@ int CBotToken::GivKeyWords(const char* w)
return -1; return -1;
} }
BOOL CBotToken::GivKeyDefNum(const char* w, CBotToken* &token) bool CBotToken::GivKeyDefNum(const char* w, CBotToken* &token)
{ {
int i; int i;
int l = m_ListKeyDefine.GivSize(); int l = m_ListKeyDefine.GivSize();
@ -454,15 +455,16 @@ BOOL CBotToken::GivKeyDefNum(const char* w, CBotToken* &token)
{ {
token->m_IdKeyWord = m_ListKeyNums[i]; token->m_IdKeyWord = m_ListKeyNums[i];
token->m_type = TokenTypDef; token->m_type = TokenTypDef;
return TRUE; return true;
} }
} }
return FALSE; return false;
} }
// reprend la liste des mots clefs dans les ressources // reprend la liste des mots clefs dans les ressources
/// \todo Fixme Figure out how this should work.
void CBotToken::LoadKeyWords() void CBotToken::LoadKeyWords()
{ {
CBotString s; CBotString s;
@ -498,36 +500,36 @@ 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.GivSize();
for (i = 0; i < l; i++) for (i = 0; i < l; i++)
{ {
if (m_ListKeyDefine[i] == name) return FALSE; if (m_ListKeyDefine[i] == name) return false;
} }
if ( i == MAXDEFNUM ) return FALSE; if ( i == MAXDEFNUM ) return false;
m_ListKeyDefine.Add( name ); m_ListKeyDefine.Add( name );
m_ListKeyNums[i] = val; m_ListKeyNums[i] = val;
return TRUE; return true;
} }
BOOL IsOfType(CBotToken* &p, int type1, int type2) bool IsOfType(CBotToken* &p, int type1, int type2)
{ {
if (p->GivType() == type1 || if (p->GivType() == type1 ||
p->GivType() == type2 ) p->GivType() == type2 )
{ {
p = p->GivNext(); p = p->GivNext();
return TRUE; return true;
} }
return FALSE; return false;
} }
// idem avec un nombre indéfini d'arguments // idem avec un nombre indéfini d'arguments
// il faut mettre un zéro comme dernier argument // il faut mettre un zéro comme dernier argument
BOOL IsOfTypeList(CBotToken* &p, int type1, ...) bool IsOfTypeList(CBotToken* &p, int type1, ...)
{ {
int i = type1; int i = type1;
int max = 20; int max = 20;
@ -536,18 +538,18 @@ BOOL IsOfTypeList(CBotToken* &p, int type1, ...)
va_list marker; va_list marker;
va_start( marker, type1 ); /* Initialize variable arguments. */ va_start( marker, type1 ); /* Initialize variable arguments. */
while (TRUE) while (true)
{ {
if (type == i) if (type == i)
{ {
p = p->GivNext(); p = p->GivNext();
va_end( marker ); /* Reset variable arguments. */ va_end( marker ); /* Reset variable arguments. */
return TRUE; return true;
} }
if (--max == 0 || 0 == (i = va_arg( marker, int))) if (--max == 0 || 0 == (i = va_arg( marker, int)))
{ {
va_end( marker ); /* Reset variable arguments. */ va_end( marker ); /* Reset variable arguments. */
return FALSE; return false;
} }
} }
} }

View File

@ -33,5 +33,5 @@
// ) // )
extern BOOL IsOfType(CBotToken* &p, int type1, int type2 = -1); extern bool IsOfType(CBotToken* &p, int type1, int type2 = -1);
extern BOOL IsOfTypeList(CBotToken* &p, int type1, ...); extern bool IsOfTypeList(CBotToken* &p, int type1, ...);

View File

@ -95,19 +95,19 @@ static int ListOp[] =
0, 0,
}; };
BOOL IsInList( int val, int* list, int& typemasque ) bool IsInList( int val, int* list, int& typemasque )
{ {
while (TRUE) while (true)
{ {
if ( *list == 0 ) return FALSE; if ( *list == 0 ) return false;
typemasque = *list++; typemasque = *list++;
if ( *list++ == val ) return TRUE; if ( *list++ == val ) return true;
} }
} }
BOOL TypeOk( int type, int test ) bool TypeOk( int type, int test )
{ {
while (TRUE) while (true)
{ {
if ( type == 0 ) return (test & 1); if ( type == 0 ) return (test & 1);
type--; test /= 2; type--; test /= 2;
@ -279,43 +279,43 @@ 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 ->GivInit() > IS_DEF || right->GivInit() > IS_DEF )
{ {
if ( err != NULL ) *err = TX_OPNAN ; if ( err != NULL ) *err = TX_OPNAN ;
return TRUE; return true;
} }
return FALSE; return false;
} }
// fait l'opération sur 2 opérandes // fait l'opération sur 2 opérandes
BOOL CBotTwoOpExpr::Execute(CBotStack* &pStack) bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
{ {
CBotStack* pStk1 = pStack->AddStack(this); // ajoute un élément à la pile CBotStack* pStk1 = pStack->AddStack(this); // ajoute un élément à la pile
// ou le retrouve en cas de reprise // ou le retrouve en cas de reprise
// if ( pStk1 == EOX ) return TRUE; // if ( pStk1 == EOX ) return true;
// selon la reprise, on peut être dans l'un des 2 états // selon la reprise, on peut être dans l'un des 2 états
if ( pStk1->GivState() == 0 ) // 1er état, évalue l'opérande de gauche if ( pStk1->GivState() == 0 ) // 1er état, évalue l'opérande de gauche
{ {
if (!m_leftop->Execute(pStk1) ) return FALSE; // interrompu ici ? if (!m_leftop->Execute(pStk1) ) return false; // interrompu ici ?
// pour les OU et ET logique, n'évalue pas la seconde expression si pas nécessaire // pour les OU et ET logique, n'évalue pas la seconde expression si pas nécessaire
if ( (GivTokenType() == ID_LOG_AND || GivTokenType() == ID_TXT_AND ) && pStk1->GivVal() == FALSE ) if ( (GivTokenType() == ID_LOG_AND || GivTokenType() == ID_TXT_AND ) && pStk1->GivVal() == 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); // transmet le résultat return pStack->Return(pStk1); // transmet le résultat
} }
if ( (GivTokenType() == ID_LOG_OR||GivTokenType() == ID_TXT_OR) && pStk1->GivVal() == TRUE ) if ( (GivTokenType() == ID_LOG_OR||GivTokenType() == ID_TXT_OR) && pStk1->GivVal() == true )
{ {
CBotVar* res = CBotVar::Create( (CBotToken*)NULL, CBotTypBoolean); CBotVar* res = CBotVar::Create( (CBotToken*)NULL, CBotTypBoolean);
res->SetValInt(TRUE); res->SetValInt(true);
pStk1->SetVar(res); pStk1->SetVar(res);
return pStack->Return(pStk1); // transmet le résultat return pStack->Return(pStk1); // transmet le résultat
} }
@ -334,7 +334,7 @@ BOOL CBotTwoOpExpr::Execute(CBotStack* &pStack)
// 2e état, évalue l'opérande de droite // 2e état, évalue l'opérande de droite
if ( pStk2->GivState() == 0 ) if ( pStk2->GivState() == 0 )
{ {
if ( !m_rightop->Execute(pStk2) ) return FALSE; // interrompu ici ? if ( !m_rightop->Execute(pStk2) ) return false; // interrompu ici ?
pStk2->IncState(); pStk2->IncState();
} }
@ -342,7 +342,7 @@ BOOL CBotTwoOpExpr::Execute(CBotStack* &pStack)
CBotTypResult type2 = pStk2->GivTypResult(); CBotTypResult type2 = pStk2->GivTypResult();
CBotStack* pStk3 = pStk2->AddStack(this); // ajoute un élément à la pile CBotStack* pStk3 = pStk2->AddStack(this); // ajoute un élément à la pile
if ( pStk3->IfStep() ) return FALSE; // montre l'opération si step by step if ( pStk3->IfStep() ) return false; // montre l'opération si step by step
// crée une variable temporaire pour y mettre le résultat // crée une variable temporaire pour y mettre le résultat
// quel est le type du résultat ? // quel est le type du résultat ?
@ -475,7 +475,7 @@ BOOL CBotTwoOpExpr::Execute(CBotStack* &pStack)
return pStack->Return(pStk2); // transmet le résultat return pStack->Return(pStk2); // transmet le résultat
} }
void CBotTwoOpExpr::RestoreState(CBotStack* &pStack, BOOL bMain) void CBotTwoOpExpr::RestoreState(CBotStack* &pStack, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
CBotStack* pStk1 = pStack->RestoreStack(this); // ajoute un élément à la pile CBotStack* pStk1 = pStack->RestoreStack(this); // ajoute un élément à la pile
@ -501,31 +501,31 @@ void CBotTwoOpExpr::RestoreState(CBotStack* &pStack, BOOL bMain)
} }
BOOL CBotLogicExpr::Execute(CBotStack* &pStack) bool CBotLogicExpr::Execute(CBotStack* &pStack)
{ {
CBotStack* pStk1 = pStack->AddStack(this); // ajoute un élément à la pile CBotStack* pStk1 = pStack->AddStack(this); // ajoute un élément à la pile
// ou le retrouve en cas de reprise // ou le retrouve en cas de reprise
// if ( pStk1 == EOX ) return TRUE; // if ( pStk1 == EOX ) return true;
if ( pStk1->GivState() == 0 ) if ( pStk1->GivState() == 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->GivVal() == true )
{ {
if ( !m_op1->Execute(pStk1) ) return FALSE; if ( !m_op1->Execute(pStk1) ) return false;
} }
else else
{ {
if ( !m_op2->Execute(pStk1) ) return FALSE; if ( !m_op2->Execute(pStk1) ) return false;
} }
return pStack->Return(pStk1); // transmet le résultat return pStack->Return(pStk1); // transmet le résultat
} }
void CBotLogicExpr::RestoreState(CBotStack* &pStack, BOOL bMain) void CBotLogicExpr::RestoreState(CBotStack* &pStack, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
@ -538,7 +538,7 @@ void CBotLogicExpr::RestoreState(CBotStack* &pStack, BOOL bMain)
return; return;
} }
if ( pStk1->GivVal() == TRUE ) if ( pStk1->GivVal() == true )
{ {
m_op1->RestoreState(pStk1, bMain); m_op1->RestoreState(pStk1, bMain);
} }
@ -557,7 +557,7 @@ void t()
#endif #endif
#if 01 #if 01
void t(BOOL t) void t(bool t)
{ {
int x; int x;
x = 1 + t ? 1 : 3 + 4 * 2 ; x = 1 + t ? 1 : 3 + 4 * 2 ;

File diff suppressed because it is too large Load Diff

View File

@ -66,7 +66,7 @@ CBotInstr* CBotWhile::Compile(CBotToken* &p, CBotCStack* pStack)
// la condition existe // la condition existe
IncLvl(inst->m_label); IncLvl(inst->m_label);
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true );
DecLvl(); DecLvl();
if ( pStk->IsOk() ) if ( pStk->IsOk() )
@ -83,31 +83,31 @@ CBotInstr* CBotWhile::Compile(CBotToken* &p, CBotCStack* pStack)
// exécute une instruction "while" // exécute une instruction "while"
BOOL CBotWhile :: Execute(CBotStack* &pj) bool CBotWhile :: Execute(CBotStack* &pj)
{ {
CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile
// ou le retrouve en cas de reprise // ou le retrouve en cas de reprise
// if ( pile == EOX ) return TRUE; // if ( pile == EOX ) return true;
if ( pile->IfStep() ) return FALSE; if ( pile->IfStep() ) return false;
while( TRUE ) switch( pile->GivState() ) // exécute la boucle while( true ) switch( pile->GivState() ) // exécute la boucle
{ // il y a 2 états possibles (selon reprise) { // il y a 2 états possibles (selon reprise)
case 0: case 0:
// évalue la condition // évalue la condition
if ( !m_Condition->Execute(pile) ) return FALSE; // interrompu ici ? if ( !m_Condition->Execute(pile) ) return false; // interrompu ici ?
// le résultat de la condition est sur la pile // le résultat de la condition est sur la pile
// termine s'il y a une erreur ou si la condition est fausse // termine s'il y a une erreur ou si la condition est fausse
if ( !pile->IsOk() || pile->GivVal() != TRUE ) if ( !pile->IsOk() || pile->GivVal() != true )
{ {
return pj->Return(pile); // transmet le résultat et libère la pile return pj->Return(pile); // transmet le résultat et libère la pile
} }
// la condition est vrai, passe dans le second mode // la condition est vrai, passe dans le second mode
if (!pile->SetState(1)) return FALSE; // prêt pour la suite if (!pile->SetState(1)) return false; // prêt pour la suite
case 1: case 1:
// évalue le bloc d'instruction associé // évalue le bloc d'instruction associé
@ -125,12 +125,12 @@ BOOL CBotWhile :: Execute(CBotStack* &pj)
} }
// repasse au test pour recommencer // repasse au test pour recommencer
if (!pile->SetState(0, 0)) return FALSE; if (!pile->SetState(0, 0)) return false;
continue; continue;
} }
} }
void CBotWhile :: RestoreState(CBotStack* &pj, BOOL bMain) void CBotWhile :: RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
CBotStack* pile = pj->RestoreStack(this); // ajoute un élément à la pile CBotStack* pile = pj->RestoreStack(this); // ajoute un élément à la pile
@ -196,7 +196,7 @@ CBotInstr* CBotRepeat::Compile(CBotToken* &p, CBotCStack* pStack)
{ {
IncLvl(inst->m_label); IncLvl(inst->m_label);
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true );
DecLvl(); DecLvl();
if ( pStk->IsOk() ) if ( pStk->IsOk() )
@ -221,19 +221,19 @@ CBotInstr* CBotRepeat::Compile(CBotToken* &p, CBotCStack* pStack)
// exécute une instruction "repeat" // exécute une instruction "repeat"
BOOL CBotRepeat :: Execute(CBotStack* &pj) bool CBotRepeat :: Execute(CBotStack* &pj)
{ {
CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile
// ou le retrouve en cas de reprise // ou le retrouve en cas de reprise
// if ( pile == EOX ) return TRUE; // if ( pile == EOX ) return true;
if ( pile->IfStep() ) return FALSE; if ( pile->IfStep() ) return false;
while( TRUE ) switch( pile->GivState() ) // exécute la boucle while( true ) switch( pile->GivState() ) // exécute la boucle
{ // il y a 2 états possibles (selon reprise) { // il y a 2 états possibles (selon reprise)
case 0: case 0:
// évalue le nombre d'itération // évalue le nombre d'itération
if ( !m_NbIter->Execute(pile) ) return FALSE; // interrompu ici ? if ( !m_NbIter->Execute(pile) ) return false; // interrompu ici ?
// le résultat de la condition est sur la pile // le résultat de la condition est sur la pile
@ -246,7 +246,7 @@ BOOL CBotRepeat :: Execute(CBotStack* &pj)
// met le nombre d'itération +1 dans le "state" // met le nombre d'itération +1 dans le "state"
if (!pile->SetState(n+1)) return FALSE; // prêt pour la suite if (!pile->SetState(n+1)) return false; // prêt pour la suite
continue; // passe à la suite continue; // passe à la suite
case 1: case 1:
@ -269,12 +269,12 @@ BOOL CBotRepeat :: Execute(CBotStack* &pj)
} }
// repasse au test pour recommencer // repasse au test pour recommencer
if (!pile->SetState(pile->GivState()-1, 0)) return FALSE; if (!pile->SetState(pile->GivState()-1, 0)) return false;
continue; continue;
} }
} }
void CBotRepeat :: RestoreState(CBotStack* &pj, BOOL bMain) void CBotRepeat :: RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
CBotStack* pile = pj->RestoreStack(this); // ajoute un élément à la pile CBotStack* pile = pj->RestoreStack(this); // ajoute un élément à la pile
@ -332,7 +332,7 @@ CBotInstr* CBotDo::Compile(CBotToken* &p, CBotCStack* pStack)
// cherche un bloc d'instruction après le do // cherche un bloc d'instruction après le do
IncLvl(inst->m_label); IncLvl(inst->m_label);
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true );
DecLvl(); DecLvl();
if ( pStk->IsOk() ) if ( pStk->IsOk() )
@ -358,15 +358,15 @@ CBotInstr* CBotDo::Compile(CBotToken* &p, CBotCStack* pStack)
// exécute une instruction "do" // exécute une instruction "do"
BOOL CBotDo :: Execute(CBotStack* &pj) bool CBotDo :: Execute(CBotStack* &pj)
{ {
CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile
// ou le retrouve en cas de reprise // ou le retrouve en cas de reprise
// if ( pile == EOX ) return TRUE; // if ( pile == EOX ) return true;
if ( pile->IfStep() ) return FALSE; if ( pile->IfStep() ) return false;
while( TRUE ) switch( pile->GivState() ) // exécute la boucle while( true ) switch( pile->GivState() ) // exécute la boucle
{ // il y a 2 états possibles (selon reprise) { // il y a 2 états possibles (selon reprise)
case 0: case 0:
// évalue le bloc d'instruction associé // évalue le bloc d'instruction associé
@ -383,27 +383,27 @@ BOOL CBotDo :: Execute(CBotStack* &pj)
return pj->Return(pile); // transmet le résultat et libère la pile return pj->Return(pile); // transmet le résultat et libère la pile
} }
if (!pile->SetState(1)) return FALSE; // prêt pour la suite if (!pile->SetState(1)) return false; // prêt pour la suite
case 1: case 1:
// évalue la condition // évalue la condition
if ( !m_Condition->Execute(pile) ) return FALSE; // interrompu ici ? if ( !m_Condition->Execute(pile) ) return false; // interrompu ici ?
// le résultat de la condition est sur la pile // le résultat de la condition est sur la pile
// termine s'il y a une erreur ou si la condition est fausse // termine s'il y a une erreur ou si la condition est fausse
if ( !pile->IsOk() || pile->GivVal() != TRUE ) if ( !pile->IsOk() || pile->GivVal() != true )
{ {
return pj->Return(pile); // transmet le résultat et libère la pile return pj->Return(pile); // transmet le résultat et libère la pile
} }
// repasse au bloc d'instruction pour recommencer // repasse au bloc d'instruction pour recommencer
if (!pile->SetState(0, 0)) return FALSE; if (!pile->SetState(0, 0)) return false;
continue; continue;
} }
} }
void CBotDo :: RestoreState(CBotStack* &pj, BOOL bMain) void CBotDo :: RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
@ -467,7 +467,7 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack)
return NULL; return NULL;
} }
CBotCStack* pStk = pStack->TokenStack(pp, TRUE); // un petit bout de pile svp CBotCStack* pStk = pStack->TokenStack(pp, true); // un petit bout de pile svp
// compile les instructions pour initialisation // compile les instructions pour initialisation
inst->m_Init = CBotListExpression::Compile( p, pStk ); inst->m_Init = CBotListExpression::Compile( p, pStk );
@ -494,7 +494,7 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack)
if ( IsOfType(p, ID_CLOSEPAR)) // manque la parenthèse ? if ( IsOfType(p, ID_CLOSEPAR)) // manque la parenthèse ?
{ {
IncLvl(inst->m_label); IncLvl(inst->m_label);
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true );
DecLvl(); DecLvl();
if ( pStk->IsOk() ) if ( pStk->IsOk() )
return pStack->Return(inst, pStk);; return pStack->Return(inst, pStk);;
@ -510,39 +510,39 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack)
// exécute l'instruction "for" // exécute l'instruction "for"
BOOL CBotFor :: Execute(CBotStack* &pj) bool CBotFor :: Execute(CBotStack* &pj)
{ {
CBotStack* pile = pj->AddStack(this, TRUE); // ajoute un élément à la pile (variables locales) CBotStack* pile = pj->AddStack(this, true); // ajoute un élément à la pile (variables locales)
// ou le retrouve en cas de reprise // ou le retrouve en cas de reprise
// if ( pile == EOX ) return TRUE; // if ( pile == EOX ) return true;
if ( pile->IfStep() ) return FALSE; if ( pile->IfStep() ) return false;
while( TRUE ) switch( pile->GivState() ) // exécute la boucle while( true ) switch( pile->GivState() ) // exécute la boucle
{ // il y a 4 états possibles (selon reprise) { // il y a 4 états possibles (selon reprise)
case 0: case 0:
// évalue l'initialisation // évalue l'initialisation
if ( m_Init != NULL && if ( m_Init != NULL &&
!m_Init->Execute(pile) ) return FALSE; // interrompu ici ? !m_Init->Execute(pile) ) return false; // interrompu ici ?
if (!pile->SetState(1)) return FALSE; // prêt pour la suite if (!pile->SetState(1)) return false; // prêt pour la suite
case 1: case 1:
// évalue la condition // évalue la condition
if ( m_Test != NULL ) // pas de condition ? -> vrai ! if ( m_Test != NULL ) // pas de condition ? -> vrai !
{ {
if (!m_Test->Execute(pile) ) return FALSE; // interrompu ici ? if (!m_Test->Execute(pile) ) return false; // interrompu ici ?
// le résultat de la condition est sur la pile // le résultat de la condition est sur la pile
// termine s'il y a une erreur ou si la condition est fausse // termine s'il y a une erreur ou si la condition est fausse
if ( !pile->IsOk() || pile->GivVal() != TRUE ) if ( !pile->IsOk() || pile->GivVal() != true )
{ {
return pj->Return(pile); // transmet le résultat et libère la pile return pj->Return(pile); // transmet le résultat et libère la pile
} }
} }
// la condition est vrai, passe à la suite // la condition est vrai, passe à la suite
if (!pile->SetState(2)) return FALSE; // prêt pour la suite if (!pile->SetState(2)) return false; // prêt pour la suite
case 2: case 2:
// évalue le bloc d'instruction associé // évalue le bloc d'instruction associé
@ -559,20 +559,20 @@ BOOL CBotFor :: Execute(CBotStack* &pj)
return pj->Return(pile); // transmet le résultat et libère la pile return pj->Return(pile); // transmet le résultat et libère la pile
} }
if (!pile->SetState(3)) return FALSE; // prêt pour la suite if (!pile->SetState(3)) return false; // prêt pour la suite
case 3: case 3:
// évalue l'incrémentation // évalue l'incrémentation
if ( m_Incr != NULL && if ( m_Incr != NULL &&
!m_Incr->Execute(pile) ) return FALSE; // interrompu ici ? !m_Incr->Execute(pile) ) return false; // interrompu ici ?
// repasse au test pour recommencer // repasse au test pour recommencer
if (!pile->SetState(1, 0)) return FALSE; // revient au test if (!pile->SetState(1, 0)) return false; // revient au test
continue; continue;
} }
} }
void CBotFor :: RestoreState(CBotStack* &pj, BOOL bMain) void CBotFor :: RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
@ -583,28 +583,28 @@ void CBotFor :: RestoreState(CBotStack* &pj, BOOL bMain)
{ // il y a 4 états possibles (selon reprise) { // il y a 4 états possibles (selon reprise)
case 0: case 0:
// évalue l'initialisation // évalue l'initialisation
if ( m_Init != NULL ) m_Init->RestoreState(pile, TRUE); // interrompu ici ! if ( m_Init != NULL ) m_Init->RestoreState(pile, true); // interrompu ici !
return; return;
case 1: case 1:
if ( m_Init != NULL ) m_Init->RestoreState(pile, FALSE); // définitions variables if ( m_Init != NULL ) m_Init->RestoreState(pile, false); // définitions variables
// évalue la condition // évalue la condition
if ( m_Test != NULL ) m_Test->RestoreState(pile, TRUE); // interrompu ici ! if ( m_Test != NULL ) m_Test->RestoreState(pile, true); // interrompu ici !
return; return;
case 2: case 2:
if ( m_Init != NULL ) m_Init->RestoreState(pile, FALSE); // définitions variables if ( m_Init != NULL ) m_Init->RestoreState(pile, false); // définitions variables
// évalue le bloc d'instruction associé // évalue le bloc d'instruction associé
if ( m_Block != NULL ) m_Block->RestoreState(pile, TRUE); if ( m_Block != NULL ) m_Block->RestoreState(pile, true);
return; return;
case 3: case 3:
if ( m_Init != NULL ) m_Init->RestoreState(pile, FALSE); // définitions variables if ( m_Init != NULL ) m_Init->RestoreState(pile, false); // définitions variables
// évalue l'incrémentation // évalue l'incrémentation
if ( m_Incr != NULL ) m_Incr->RestoreState(pile, TRUE); // interrompu ici ! if ( m_Incr != NULL ) m_Incr->RestoreState(pile, true); // interrompu ici !
return; return;
} }
} }
@ -629,10 +629,10 @@ CBotListExpression::~CBotListExpression()
static CBotInstr* CompileInstrOrDefVar(CBotToken* &p, CBotCStack* pStack) static CBotInstr* CompileInstrOrDefVar(CBotToken* &p, CBotCStack* pStack)
{ {
CBotInstr* i = CBotInt::Compile( p, pStack, FALSE, TRUE ); // est-ce une déclaration d'un entier ? CBotInstr* i = CBotInt::Compile( p, pStack, false, true ); // est-ce une déclaration d'un entier ?
if ( i== NULL ) i = CBotFloat::Compile( p, pStack, FALSE, TRUE ); // ou d'un nombre réel ? if ( i== NULL ) i = CBotFloat::Compile( p, pStack, false, true ); // ou d'un nombre réel ?
if ( i== NULL ) i = CBotBoolean::Compile( p, pStack, FALSE, TRUE ); // ou d'un booléen ? if ( i== NULL ) i = CBotBoolean::Compile( p, pStack, false, true ); // ou d'un booléen ?
if ( i== NULL ) i = CBotIString::Compile( p, pStack, FALSE, TRUE ); // ou d'une chaîne ? if ( i== NULL ) i = CBotIString::Compile( p, pStack, false, true ); // ou d'une chaîne ?
if ( i== NULL ) i = CBotExpression::Compile( p, pStack ); // compile une expression if ( i== NULL ) i = CBotExpression::Compile( p, pStack ); // compile une expression
return i; return i;
} }
@ -660,7 +660,7 @@ CBotInstr* CBotListExpression::Compile(CBotToken* &p, CBotCStack* pStack)
return NULL; return NULL;
} }
BOOL CBotListExpression::Execute(CBotStack* &pj) bool CBotListExpression::Execute(CBotStack* &pj)
{ {
CBotStack* pile = pj->AddStack();// indispensable CBotStack* pile = pj->AddStack();// indispensable
CBotInstr* p = m_Expr; // la première expression CBotInstr* p = m_Expr; // la première expression
@ -668,17 +668,17 @@ BOOL CBotListExpression::Execute(CBotStack* &pj)
int state = pile->GivState(); int state = pile->GivState();
while (state-->0) p = p->GivNext(); // revient sur l'opération interrompue while (state-->0) p = p->GivNext(); // revient sur l'opération interrompue
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->GivNext();
if ( p == NULL ) break; if ( p == NULL ) break;
if (!pile->IncState()) return FALSE; // prêt pour la suivante if (!pile->IncState()) return false; // prêt pour la suivante
} }
return pj->Return(pile); return pj->Return(pile);
} }
void CBotListExpression::RestoreState(CBotStack* &pj, BOOL bMain) void CBotListExpression::RestoreState(CBotStack* &pj, bool bMain)
{ {
CBotStack* pile = pj; CBotStack* pile = pj;
int state = 0x7000; int state = 0x7000;
@ -694,7 +694,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(); // revient sur l'opération interrompue p = p->GivNext(); // revient sur l'opération interrompue
} }
@ -770,7 +770,7 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack)
return pStack->Return(NULL, pStk); return pStack->Return(NULL, pStk);
} }
CBotInstr* i = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); CBotInstr* i = CBotBlock::CompileBlkOrInst( p, pStk, true );
if ( !pStk->IsOk() ) if ( !pStk->IsOk() )
{ {
delete inst; delete inst;
@ -811,21 +811,21 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack)
// exécute une instruction "switch" // exécute une instruction "switch"
BOOL CBotSwitch :: Execute(CBotStack* &pj) bool CBotSwitch :: Execute(CBotStack* &pj)
{ {
CBotStack* pile1 = pj->AddStack(this); // ajoute un élément à la pile CBotStack* pile1 = pj->AddStack(this); // ajoute un élément à la pile
// if ( pile1 == EOX ) return TRUE; // if ( pile1 == EOX ) return true;
CBotInstr* p = m_Block; // la première expression CBotInstr* p = m_Block; // la première expression
int state = pile1->GivState(); int state = pile1->GivState();
if (state == 0) if (state == 0)
{ {
if ( !m_Value->Execute(pile1) ) return FALSE; if ( !m_Value->Execute(pile1) ) return false;
pile1->SetState(state = -1); pile1->SetState(state = -1);
} }
if ( pile1->IfStep() ) return FALSE; if ( pile1->IfStep() ) return false;
if ( state == -1 ) if ( state == -1 )
{ {
@ -843,7 +843,7 @@ BOOL CBotSwitch :: Execute(CBotStack* &pj)
if ( p == NULL ) return pj->Return(pile1); // terminé si plus rien if ( p == NULL ) return pj->Return(pile1); // terminé si plus rien
if ( !pile1->SetState(state) ) return FALSE; if ( !pile1->SetState(state) ) return false;
} }
p = m_Block; // revient au début p = m_Block; // revient au début
@ -852,13 +852,13 @@ BOOL CBotSwitch :: Execute(CBotStack* &pj)
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->GivNext();
} }
return pj->Return(pile1); return pj->Return(pile1);
} }
void CBotSwitch :: RestoreState(CBotStack* &pj, BOOL bMain) void CBotSwitch :: RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
@ -882,13 +882,13 @@ void CBotSwitch :: RestoreState(CBotStack* &pj, BOOL bMain)
// p = m_Block; // revient au début // p = m_Block; // revient au début
while ( p != NULL && state-- > 0 ) while ( p != NULL && state-- > 0 )
{ {
p->RestoreState(pile1, FALSE); p->RestoreState(pile1, false);
p = p->GivNext(); // avance dans la liste p = p->GivNext(); // avance dans la liste
} }
if( p != NULL ) if( p != NULL )
{ {
p->RestoreState(pile1, TRUE); p->RestoreState(pile1, true);
return; return;
} }
} }
@ -942,21 +942,21 @@ CBotInstr* CBotCase::Compile(CBotToken* &p, CBotCStack* pStack)
// exécution de l'instruction "case" // exécution de l'instruction "case"
BOOL CBotCase::Execute(CBotStack* &pj) bool CBotCase::Execute(CBotStack* &pj)
{ {
return TRUE; // l'instruction "case" ne fait rien ! return true; // l'instruction "case" ne fait rien !
} }
void CBotCase::RestoreState(CBotStack* &pj, BOOL bMain) void CBotCase::RestoreState(CBotStack* &pj, bool bMain)
{ {
} }
// routine permettant de trouver le point d'entrée "case" // routine permettant de trouver le point d'entrée "case"
// correspondant à la valeur cherchée // correspondant à la valeur cherchée
BOOL CBotCase::CompCase(CBotStack* &pile, int val) bool CBotCase::CompCase(CBotStack* &pile, int val)
{ {
if ( m_Value == NULL ) return TRUE; // cas pour "default" if ( m_Value == NULL ) return true; // cas pour "default"
while (!m_Value->Execute(pile)); // met sur la pile la valeur correpondant (sans interruption) while (!m_Value->Execute(pile)); // met sur la pile la valeur correpondant (sans interruption)
return (pile->GivVal() == val); // compare avec la valeur cherchée return (pile->GivVal() == val); // compare avec la valeur cherchée
@ -1016,18 +1016,18 @@ CBotInstr* CBotBreak::Compile(CBotToken* &p, CBotCStack* pStack)
// exécution l'instructino "break" ou "continu" // exécution l'instructino "break" ou "continu"
BOOL CBotBreak :: Execute(CBotStack* &pj) bool CBotBreak :: 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->IfStep() ) return FALSE; if ( pile->IfStep() ) return false;
pile->SetBreak(m_token.GivType()==ID_BREAK ? 1 : 2, m_label); pile->SetBreak(m_token.GivType()==ID_BREAK ? 1 : 2, m_label);
return pj->Return(pile); return pj->Return(pile);
} }
void CBotBreak :: RestoreState(CBotStack* &pj, BOOL bMain) void CBotBreak :: RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( bMain ) pj->RestoreStack(this); if ( bMain ) pj->RestoreStack(this);
} }
@ -1092,14 +1092,14 @@ CBotInstr* CBotTry::Compile(CBotToken* &p, CBotCStack* pStack)
// les arrêts par suspension // les arrêts par suspension
// et les "finaly" // et les "finaly"
BOOL CBotTry :: Execute(CBotStack* &pj) bool CBotTry :: Execute(CBotStack* &pj)
{ {
int val; int val;
CBotStack* pile1 = pj->AddStack(this); // ajoute un élément à la pile CBotStack* pile1 = pj->AddStack(this); // ajoute un élément à la pile
// if ( pile1 == EOX ) return TRUE; // if ( pile1 == EOX ) return true;
if ( pile1->IfStep() ) return FALSE; if ( pile1->IfStep() ) return false;
// ou le retrouve en cas de reprise // ou le retrouve en cas de reprise
CBotStack* pile0 = pj->AddStack2(); // ajoute un élément à la pile secondaire CBotStack* pile0 = pj->AddStack2(); // ajoute un élément à la pile secondaire
CBotStack* pile2 = pile0->AddStack(); CBotStack* pile2 = pile0->AddStack();
@ -1114,14 +1114,14 @@ BOOL CBotTry :: Execute(CBotStack* &pj)
val = pile1->GivError(); val = pile1->GivError();
if ( val == 0 && CBotStack::m_initimer == 0 ) // en mode de step ? if ( val == 0 && CBotStack::m_initimer == 0 ) // en mode de step ?
return FALSE; // ne fait pas le catch return false; // ne fait pas le catch
pile1->IncState(); pile1->IncState();
pile2->SetState(val); // mémorise le numéro de l'erreur pile2->SetState(val); // mémorise le numéro de l'erreur
pile1->SetError(0); // pour l'instant il n'y a plus d'erreur ! pile1->SetError(0); // pour l'instant il n'y a plus d'erreur !
if ( val == 0 && CBotStack::m_initimer < 0 ) // en mode de step ? if ( val == 0 && CBotStack::m_initimer < 0 ) // en mode de step ?
return FALSE; // ne fait pas le catch return false; // ne fait pas le catch
} }
// il y a eu une interruption // il y a eu une interruption
@ -1137,16 +1137,16 @@ BOOL CBotTry :: Execute(CBotStack* &pj)
if ( --state <= 0 ) if ( --state <= 0 )
{ {
// demande au bloc catch s'il se sent concerné // demande au bloc catch s'il se sent concerné
if ( !pc->TestCatch(pile2, val) ) return FALSE; // suspendu ! if ( !pc->TestCatch(pile2, val) ) return false; // suspendu !
pile1->IncState(); pile1->IncState();
} }
if ( --state <= 0 ) if ( --state <= 0 )
{ {
if ( pile2->GivVal() == TRUE ) if ( pile2->GivVal() == true )
{ {
// pile0->SetState(1); // pile0->SetState(1);
if ( !pc->Execute(pile2) ) return FALSE; // exécute l'opération if ( !pc->Execute(pile2) ) return false; // exécute l'opération
if ( m_FinalInst == NULL ) if ( m_FinalInst == NULL )
return pj->Return(pile2); // termine le try return pj->Return(pile2); // termine le try
@ -1164,7 +1164,7 @@ BOOL CBotTry :: Execute(CBotStack* &pj)
{ {
// 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); // garde cette exception if (!pile2->IsOk()) return pj->Return(pile2); // garde cette exception
pile2->SetError(pile1->GivState()==-1 ? val : 0); // remet l'erreur initiale pile2->SetError(pile1->GivState()==-1 ? val : 0); // remet l'erreur initiale
return pj->Return(pile2); return pj->Return(pile2);
@ -1176,11 +1176,11 @@ BOOL CBotTry :: Execute(CBotStack* &pj)
return pj->Return(pile2); // termine le try sans exception aucune return pj->Return(pile2); // termine le try sans exception aucune
pile1->SetError(val); // remet l'erreur pile1->SetError(val); // remet l'erreur
return FALSE; // ce n'est pas pour nous return false; // ce n'est pas pour nous
} }
void CBotTry :: RestoreState(CBotStack* &pj, BOOL bMain) void CBotTry :: RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
@ -1217,7 +1217,7 @@ void CBotTry :: RestoreState(CBotStack* &pj, BOOL bMain)
} }
if ( --state <= 0 ) if ( --state <= 0 )
{ {
if ( pile2->GivVal() == TRUE ) if ( pile2->GivVal() == true )
{ {
pc->RestoreState(pile2, bMain); // exécute l'opération pc->RestoreState(pile2, bMain); // exécute l'opération
return; return;
@ -1285,27 +1285,27 @@ CBotCatch* CBotCatch::Compile(CBotToken* &p, CBotCStack* pStack)
// exécution de "catch" // exécution de "catch"
BOOL CBotCatch :: Execute(CBotStack* &pj) bool CBotCatch :: Execute(CBotStack* &pj)
{ {
if ( m_Block == NULL ) return TRUE; if ( m_Block == NULL ) return true;
return m_Block->Execute(pj); // exécute le bloc associé return m_Block->Execute(pj); // exécute le bloc associé
} }
void CBotCatch :: RestoreState(CBotStack* &pj, BOOL bMain) void CBotCatch :: RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( bMain && m_Block != NULL ) m_Block->RestoreState(pj, bMain); if ( bMain && m_Block != NULL ) m_Block->RestoreState(pj, bMain);
} }
void CBotCatch :: RestoreCondState(CBotStack* &pj, BOOL bMain) void CBotCatch :: RestoreCondState(CBotStack* &pj, bool bMain)
{ {
m_Cond->RestoreState(pj, bMain); m_Cond->RestoreState(pj, bMain);
} }
// routine pour savoir si le catch est à faire ou non // routine pour savoir si le catch est à faire ou non
BOOL CBotCatch :: TestCatch(CBotStack* &pile, int val) 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->GivType() != CBotTypBoolean )
{ {
@ -1314,7 +1314,7 @@ BOOL CBotCatch :: TestCatch(CBotStack* &pile, int val)
pile->SetVar(var); // remet sur la pile pile->SetVar(var); // remet sur la pile
} }
return TRUE; return true;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -1359,18 +1359,18 @@ CBotInstr* CBotThrow::Compile(CBotToken* &p, CBotCStack* pStack)
// exécute l'instruction "throw" // exécute l'instruction "throw"
BOOL CBotThrow :: Execute(CBotStack* &pj) 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->GivState() == 0 )
{ {
if ( !m_Value->Execute(pile) ) return FALSE; if ( !m_Value->Execute(pile) ) return false;
pile->IncState(); pile->IncState();
} }
if ( pile->IfStep() ) return FALSE; if ( pile->IfStep() ) return false;
int val = pile->GivVal(); int val = pile->GivVal();
if ( val < 0 ) val = TX_BADTHROW; if ( val < 0 ) val = TX_BADTHROW;
@ -1378,7 +1378,7 @@ BOOL CBotThrow :: Execute(CBotStack* &pj)
return pj->Return( pile ); return pj->Return( pile );
} }
void CBotThrow :: RestoreState(CBotStack* &pj, BOOL bMain) void CBotThrow :: RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
@ -1417,11 +1417,11 @@ CBotInstr* CBotStartDebugDD::Compile(CBotToken* &p, CBotCStack* pStack)
// exécute l'instruction "throw" // exécute l'instruction "throw"
BOOL CBotStartDebugDD :: Execute(CBotStack* &pj) bool CBotStartDebugDD :: Execute(CBotStack* &pj)
{ {
CBotProgram* p = pj->GivBotCall(); CBotProgram* p = pj->GivBotCall();
p->m_bDebugDD = TRUE; p->m_bDebugDD = true;
return TRUE; return true;
} }

View File

@ -10,7 +10,6 @@ CBotToken.cpp
CBotTwoOpExpr.cpp CBotTwoOpExpr.cpp
CBotVar.cpp CBotVar.cpp
CBotWhile.cpp CBotWhile.cpp
CBot.rc
) )
add_library(CBot SHARED ${SOURCES}) add_library(CBot SHARED ${SOURCES})

View File

@ -58,7 +58,7 @@ void PrepareFilename(CBotString &filename) //DD!
// reçois le nom du fichier en paramètre // reçois le nom du fichier en paramètre
// exécution // exécution
BOOL rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{ {
CBotString mode; CBotString mode;
@ -132,7 +132,7 @@ CBotTypResult cfconstruct (CBotVar* pThis, CBotVar* &pVar)
// destructeur de la classe // destructeur de la classe
// exécution // exécution
BOOL rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) bool rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{ {
// récupère l'élément "handle" // récupère l'élément "handle"
pVar = pThis->GivItem("handle"); pVar = pThis->GivItem("handle");
@ -154,7 +154,7 @@ BOOL rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception
// reçois le mode r/w en paramètre // reçois le mode r/w en paramètre
// exécution // exécution
BOOL rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) bool rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{ {
// il doit y avoir un paramètre // il doit y avoir un paramètre
if ( pVar == NULL ) { Exception = CBotErrLowParam; return FALSE; } if ( pVar == NULL ) { Exception = CBotErrLowParam; return FALSE; }
@ -243,7 +243,7 @@ CBotTypResult cfopen (CBotVar* pThis, CBotVar* &pVar)
// méthode FILE :: close // méthode FILE :: close
// exécution // exécution
BOOL rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) bool rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{ {
// il ne doit pas y avoir de paramètre // il ne doit pas y avoir de paramètre
if ( pVar != NULL ) return CBotErrOverParam; if ( pVar != NULL ) return CBotErrOverParam;
@ -275,7 +275,7 @@ CBotTypResult cfclose (CBotVar* pThis, CBotVar* &pVar)
// méthode FILE :: writeln // méthode FILE :: writeln
// exécution // exécution
BOOL rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) bool rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{ {
// il doit y avoir un paramètre // il doit y avoir un paramètre
if ( pVar == NULL ) { Exception = CBotErrLowParam; return FALSE; } if ( pVar == NULL ) { Exception = CBotErrLowParam; return FALSE; }
@ -319,7 +319,7 @@ CBotTypResult cfwrite (CBotVar* pThis, CBotVar* &pVar)
// méthode FILE :: readln // méthode FILE :: readln
// exécution // exécution
BOOL rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) bool rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{ {
// il ne doit pas y avoir de paramètre // il ne doit pas y avoir de paramètre
if ( pVar != NULL ) { Exception = CBotErrOverParam; return FALSE; } if ( pVar != NULL ) { Exception = CBotErrOverParam; return FALSE; }
@ -360,7 +360,7 @@ CBotTypResult cfread (CBotVar* pThis, CBotVar* &pVar)
// exécution // exécution
BOOL rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) bool rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{ {
// il ne doit pas y avoir de paramètre // il ne doit pas y avoir de paramètre
if ( pVar != NULL ) { Exception = CBotErrOverParam; return FALSE; } if ( pVar != NULL ) { Exception = CBotErrOverParam; return FALSE; }

View File

@ -18,23 +18,23 @@
// donne la longueur d'une chaîne // donne la longueur d'une chaîne
// exécution // exécution
BOOL rStrLen( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) bool rStrLen( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
{ {
// il faut un paramètre // il faut un paramètre
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// qui doit être une string // qui doit être une string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// pas de second paramètre // pas de second paramètre
if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return TRUE; } if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return true; }
// recupére le contenu de la string // recupére le contenu de la string
CBotString s = pVar->GivValString(); CBotString s = pVar->GivValString();
// met la longueur sur la pile // met la longueur sur la pile
pResult->SetValInt( s.GivLength() ); pResult->SetValInt( s.GivLength() );
return TRUE; return true;
} }
// int xxx ( string ) // int xxx ( string )
@ -60,36 +60,36 @@ CBotTypResult cIntStr( CBotVar* &pVar, void* pUser )
// donne la partie gauche d'une chaîne // donne la partie gauche d'une chaîne
// exécution // exécution
BOOL rStrLeft( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) bool rStrLeft( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
{ {
// il faut un paramètre // il faut un paramètre
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// qui doit être une string // qui doit être une string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// recupére le contenu de la string // recupére le contenu de la string
CBotString s = pVar->GivValString(); CBotString s = pVar->GivValString();
// il faut un second paramètre // il faut un second paramètre
pVar = pVar->GivNext(); pVar = pVar->GivNext();
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// qui doit être un nombre // qui doit être un nombre
if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return TRUE; } if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; }
// récupère ce nombre // récupère ce nombre
int n = pVar->GivValInt(); int n = pVar->GivValInt();
// pas de 3e paramètre // pas de 3e paramètre
if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return TRUE; } if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return true; }
// prend la partie intéressante // prend la partie intéressante
s = s.Left( n ); s = s.Left( n );
// la met sur la pile // la met sur la pile
pResult->SetValString( s ); pResult->SetValString( s );
return TRUE; return true;
} }
// string xxx ( string, int ) // string xxx ( string, int )
@ -122,58 +122,58 @@ CBotTypResult cStrStrInt( CBotVar* &pVar, void* pUser )
// donne la partie droite d'une chaîne // donne la partie droite d'une chaîne
// exécution // exécution
BOOL rStrRight( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) bool rStrRight( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
{ {
// il faut un paramètre // il faut un paramètre
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// qui doit être une string // qui doit être une string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// recupére le contenu de la string // recupére le contenu de la string
CBotString s = pVar->GivValString(); CBotString s = pVar->GivValString();
// il faut un second paramètre // il faut un second paramètre
pVar = pVar->GivNext(); pVar = pVar->GivNext();
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// qui doit être un nombre // qui doit être un nombre
if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return TRUE; } if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; }
// récupère ce nombre // récupère ce nombre
int n = pVar->GivValInt(); int n = pVar->GivValInt();
// pas de 3e paramètre // pas de 3e paramètre
if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return TRUE; } if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return true; }
// prend la partie intéressante // prend la partie intéressante
s = s.Right( n ); s = s.Right( n );
// la met sur la pile // la met sur la pile
pResult->SetValString( s ); pResult->SetValString( s );
return TRUE; return true;
} }
// donne la partie centrale d'une chaîne // donne la partie centrale d'une chaîne
// exécution // exécution
BOOL rStrMid( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) bool rStrMid( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
{ {
// il faut un paramètre // il faut un paramètre
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// qui doit être une string // qui doit être une string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// recupére le contenu de la string // recupére le contenu de la string
CBotString s = pVar->GivValString(); CBotString s = pVar->GivValString();
// il faut un second paramètre // il faut un second paramètre
pVar = pVar->GivNext(); pVar = pVar->GivNext();
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// qui doit être un nombre // qui doit être un nombre
if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return TRUE; } if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; }
// récupère ce nombre // récupère ce nombre
int n = pVar->GivValInt(); int n = pVar->GivValInt();
@ -184,13 +184,13 @@ BOOL rStrMid( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
pVar = pVar->GivNext(); pVar = pVar->GivNext();
// qui doit être un nombre // qui doit être un nombre
if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return TRUE; } if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; }
// récupère ce nombre // récupère ce nombre
int l = pVar->GivValInt(); int l = pVar->GivValInt();
// mais pas de 4e paramètre // mais pas de 4e paramètre
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return TRUE; } if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
// prend la partie intéressante // prend la partie intéressante
s = s.Mid( n, l ); s = s.Mid( n, l );
@ -203,7 +203,7 @@ BOOL rStrMid( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
// la met sur la pile // la met sur la pile
pResult->SetValString( s ); pResult->SetValString( s );
return TRUE; return true;
} }
// donne la partie centrale d'une chaîne // donne la partie centrale d'une chaîne
@ -247,25 +247,25 @@ CBotTypResult cStrStrIntInt( CBotVar* &pVar, void* pUser )
// donne le nombre contenu dans une chaîne // donne le nombre contenu dans une chaîne
// exécution // exécution
BOOL rStrVal( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) bool rStrVal( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
{ {
// il faut un paramètre // il faut un paramètre
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// qui doit être une string // qui doit être une string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// recupére le contenu de la string // recupére le contenu de la string
CBotString s = pVar->GivValString(); CBotString s = pVar->GivValString();
// mais pas de 2e paramètre // mais pas de 2e paramètre
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return TRUE; } if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
float val = GivNumFloat(s); float val = GivNumFloat(s);
// la met la valeur sur la pile // la met la valeur sur la pile
pResult->SetValFloat( val ); pResult->SetValFloat( val );
return TRUE; return true;
} }
// float xxx ( string ) // float xxx ( string )
@ -291,35 +291,35 @@ CBotTypResult cFloatStr( CBotVar* &pVar, void* pUser )
// trouve une chaine dans une autre // trouve une chaine dans une autre
// exécution // exécution
BOOL rStrFind( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) bool rStrFind( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
{ {
// il faut un paramètre // il faut un paramètre
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// qui doit être une string // qui doit être une string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// recupére le contenu de la string // recupére le contenu de la string
CBotString s = pVar->GivValString(); CBotString s = pVar->GivValString();
// il faut un second paramètre // il faut un second paramètre
pVar = pVar->GivNext(); pVar = pVar->GivNext();
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// qui doit être une string // qui doit être une string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// récupère ce nombre // récupère ce nombre
CBotString s2 = pVar->GivValString(); CBotString s2 = pVar->GivValString();
// pas de 3e paramètre // pas de 3e paramètre
if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return TRUE; } if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return true; }
// met le résultat sur la pile // met le résultat sur la pile
int res = s.Find(s2); int res = s.Find(s2);
pResult->SetValInt( res ); pResult->SetValInt( res );
if ( res < 0 ) pResult->SetInit( IS_NAN ); if ( res < 0 ) pResult->SetInit( IS_NAN );
return TRUE; return true;
} }
// int xxx ( string, string ) // int xxx ( string, string )
@ -352,51 +352,51 @@ CBotTypResult cIntStrStr( CBotVar* &pVar, void* pUser )
// donne une chaine en majuscule // donne une chaine en majuscule
// exécution // exécution
BOOL rStrUpper( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) bool rStrUpper( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
{ {
// il faut un paramètre // il faut un paramètre
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// qui doit être une string // qui doit être une string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// recupére le contenu de la string // recupére le contenu de la string
CBotString s = pVar->GivValString(); CBotString s = pVar->GivValString();
// mais pas de 2e paramètre // mais pas de 2e paramètre
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return TRUE; } if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
s.MakeUpper(); s.MakeUpper();
// la met la valeur sur la pile // la met la valeur sur la pile
pResult->SetValString( s ); pResult->SetValString( s );
return TRUE; return true;
} }
// donne une chaine en minuscules // donne une chaine en minuscules
// exécution // exécution
BOOL rStrLower( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) bool rStrLower( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
{ {
// il faut un paramètre // il faut un paramètre
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// qui doit être une string // qui doit être une string
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
// recupére le contenu de la string // recupére le contenu de la string
CBotString s = pVar->GivValString(); CBotString s = pVar->GivValString();
// mais pas de 2e paramètre // mais pas de 2e paramètre
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return TRUE; } if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
s.MakeLower(); s.MakeLower();
// la met la valeur sur la pile // la met la valeur sur la pile
pResult->SetValString( s ); pResult->SetValString( s );
return TRUE; return true;
} }
// string xxx ( string ) // string xxx ( string )

View File

@ -1,39 +1,41 @@
pour la gestion des instances d'une classe.
l'objet créé actuellement avec CBotVar::Create(nom, pClasse) for managing instances of a class.
est a conserver tel quel, en dehors des vars sur la pile
il faut un autre type de variable pour garder les pointeurs the object being created with CBotVar :: Create (name, pClasse)
CBotTypPtClass par exemple is to keep as is, outside the vars on the stack
L'instance de la classe doit avoir un compteur d'utilisation we need another type of variable to keep the pointers
qui est le nombre d'objet de classe CBotTypPtClass qui y réfèrent. For example CBotTypPtClass
Le compteur est décrémenté lorsque le pointeur est détruit,
l'objet supprimé lorsqu'il n'y a plus de pointeurs. The instance of the class must have a usage count
which is the number of class object to which they refer CBotTypPtClass.
The counter is decremented when the pointer is destroyed,
be deleted when there is more pointers.
Dans le cas des robots, Daniel crée une instance de sa classe "Object" In the case of robots, Daniel creates an instance of class "Object"
et peut retourner des pointeurs à cette instance par des routines genre FindRobot() and can return pointers to this proceeding by routines such FindRobot ()
Object FindRobot(int n) { } Object FindRobot (int n) {}
pResult dans ce cas est un pointeur CBotTypPtClass pResult in this case is a pointer CBotTypPtClass
lorsqu'il a trouvé le robot concerné, il lui faudra faire when he found the robot concerned, it must make
pResult->SetPointeur(InstanceDeLaClassObject); pResult-> SetPointeur (InstanceDeLaClassObject);
cette opération incrémente le compteur des références this operation increments the reference
-- -
lorsque le robot est détruit, l'instance de la classe Object correspondant when the robot is destroyed, the instance of the Object class corresponding
est détruit également. is also destroyed.
s'il reste des pointeurs à cet objet, et l'on risque la planté if there are pointers to that object, and we planted the risk
solution 1: Solution 1:
garder non pas le pointeur à l'objet directement, mais not keep the pointer to the object directly, but
un index dans une tables de pointeurs an index into a table of pointers
Solution 2:
not destroy the object when there imédiatement pointers
but marked as virtually destroyed
solution 2:
ne pas détruire l'objet imédiatement lorsqu'il reste des pointeurs
mais le marqué comme virtuellement détruit

View File

@ -1,15 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.

View File

@ -13,100 +13,105 @@
// * // *
// * You should have received a copy of the GNU General Public License // * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.//{{NO_DEPENDENCIES}} // * along with this program. If not, see http://www.gnu.org/licenses/.//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file. #ifndef _RESOURCE_H_
// Used by CBot.rc #define _RESOURCE_H_
//
#define ID_KEYWORDS 2000 enum EID
#define ID_IF 2000 {
#define ID_ELSE 2001 ID_IF = 2000,
#define ID_WHILE 2002 ID_ELSE,
#define ID_DO 2003 ID_WHILE,
#define ID_FOR 2004 ID_DO,
#define ID_BREAK 2005 ID_FOR,
#define ID_CONTINUE 2006 ID_BREAK,
#define ID_SWITCH 2007 ID_CONTINUE,
#define ID_CASE 2008 ID_SWITCH,
#define ID_DEFAULT 2009 ID_CASE,
#define ID_TRY 2010 ID_DEFAULT,
#define ID_THROW 2011 ID_TRY,
#define ID_CATCH 2012 ID_THROW,
#define ID_FINALLY 2013 ID_CATCH,
#define ID_TXT_AND 2014 ID_FINALLY,
#define ID_TXT_OR 2015 ID_TXT_AND,
#define ID_TXT_NOT 2016 ID_TXT_OR,
#define ID_RETURN 2017 ID_TXT_NOT,
#define ID_CLASS 2018 ID_RETURN,
#define ID_EXTENDS 2019 ID_CLASS,
#define ID_SYNCHO 2020 ID_EXTENDS,
#define ID_NEW 2021 ID_SYNCHO,
#define ID_PUBLIC 2022 ID_NEW,
#define ID_EXTERN 2023 ID_PUBLIC,
#define ID_FINAL 2024 ID_EXTERN,
#define ID_STATIC 2025 ID_FINAL,
#define ID_PROTECTED 2026 ID_STATIC,
#define ID_PRIVATE 2027 ID_PROTECTED,
#define ID_REPEAT 2028 ID_PRIVATE,
#define ID_DEBUGDD 2099 ID_REPEAT,
#define ID_INT 2100 ID_DEBUGDD,
#define ID_FLOAT 2101 ID_INT,
#define ID_BOOLEAN 2102 ID_FLOAT,
#define ID_STRING 2103 ID_BOOLEAN,
#define ID_VOID 2104 ID_STRING,
#define ID_BOOL 2105 ID_VOID,
#define ID_TRUE 2200 ID_BOOL,
#define ID_FALSE 2201
#define ID_NULL 2202 ID_TRUE = 2200,
#define ID_NAN 2203 ID_FALSE,
#define ID_OPENPAR 2300 ID_NULL,
#define ID_CLOSEPAR 2301 ID_NAN,
#define ID_OPBLK 2302
#define ID_CLBLK 2303 ID_OPENPAR = 2300,
#define ID_SEP 2304 ID_CLOSEPAR,
#define ID_COMMA 2305 ID_OPBLK,
#define ID_DOTS 2306 ID_CLBLK,
#define ID_DOT 2307 ID_SEP,
#define ID_OPBRK 2308 ID_COMMA,
#define ID_CLBRK 2309 ID_DOTS,
#define ID_DBLDOTS 2310 ID_DOT,
#define ID_LOGIC 2311 ID_OPBRK,
#define ID_ADD 2312 ID_CLBRK,
#define ID_SUB 2313 ID_DBLDOTS,
#define ID_MUL 2314 ID_LOGIC,
#define ID_DIV 2315 ID_ADD,
#define ID_ASS 2316 ID_SUB,
#define ID_ASSADD 2317 ID_MUL,
#define ID_ASSSUB 2318 ID_DIV,
#define ID_ASSMUL 2319 ID_ASS,
#define ID_ASSDIV 2320 ID_ASSADD,
#define ID_ASSOR 2321 ID_ASSSUB,
#define ID_ASSAND 2322 ID_ASSMUL,
#define ID_ASSXOR 2323 ID_ASSDIV,
#define ID_ASSSL 2324 ID_ASSOR,
#define ID_ASSSR 2325 ID_ASSAND,
#define ID_ASSASR 2326 ID_ASSXOR,
#define ID_SL 2327 ID_ASSSL,
#define ID_SR 2328 ID_ASSSR,
#define ID_ASR 2329 ID_ASSASR,
#define ID_INC 2330 ID_SL,
#define ID_DEC 2331 ID_SR,
#define ID_LO 2332 ID_ASR,
#define ID_HI 2333 ID_INC,
#define ID_LS 2334 ID_DEC,
#define ID_HS 2335 ID_LO,
#define ID_EQ 2336 ID_HI,
#define ID_NE 2337 ID_LS,
#define ID_AND 2338 ID_HS,
#define ID_XOR 2339 ID_EQ,
#define ID_OR 2340 ID_NE,
#define ID_LOG_AND 2341 ID_AND,
#define ID_LOG_OR 2342 ID_XOR,
#define ID_LOG_NOT 2343 ID_OR,
#define ID_NOT 2344 ID_LOG_AND,
#define ID_MODULO 2345 ID_LOG_OR,
#define ID_POWER 2346 ID_LOG_NOT,
#define ID_ASSMODULO 2347 ID_NOT,
#define TX_UNDEF 4000 ID_MODULO,
#define TX_NAN 4001 ID_POWER,
ID_ASSMODULO,
TX_UNDEF = 4000,
TX_NAN,
ID_SUPER = 6000
};
#define TX_OPENPAR 5000 #define TX_OPENPAR 5000
#define TX_CLOSEPAR 5001 #define TX_CLOSEPAR 5001
#define TX_NOTBOOL 5002 #define TX_NOTBOOL 5002
@ -166,15 +171,6 @@
#define TX_NOTOPEN 6013 #define TX_NOTOPEN 6013
#define TX_ERRREAD 6014 #define TX_ERRREAD 6014
#define TX_ERRWRITE 6015 #define TX_ERRWRITE 6015
#define ID_SUPER 62020
// Next default values for new objects #endif //_RESOURCE_H_
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -1,5 +1,5 @@
# CBot shared library is built separately # CBot shared library is built separately
# add_subdirectory(CBot) -- not yet WinAPI-independent add_subdirectory(CBot)
# Configure options # Configure options
@ -29,6 +29,7 @@ configure_file(common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h
# Source files # Source files
# Commented out files are still dependent on DirectX or WinAPI # Commented out files are still dependent on DirectX or WinAPI
set(SOURCES set(SOURCES
app/app.cpp app/app.cpp
app/main.cpp app/main.cpp
@ -155,8 +156,8 @@ ${SDL_LIBRARY}
${SDLIMAGE_LIBRARY} ${SDLIMAGE_LIBRARY}
${OPENGL_LIBRARY} ${OPENGL_LIBRARY}
${PNG_LIBRARIES} ${PNG_LIBRARIES}
#CBot -- not yet WinAPI-independent
${PLATFORM_LIBS} ${PLATFORM_LIBS}
CBot
) )
include_directories(. ${CMAKE_CURRENT_BINARY_DIR} include_directories(. ${CMAKE_CURRENT_BINARY_DIR}

View File

@ -28,6 +28,9 @@
#include <plugins/plugin.h> #include <plugins/plugin.h>
#include <string>
/*! /*!
* Maximum possible audio volume * Maximum possible audio volume
*/ */