From 26f91499473ce0f7738fee0931a337ef19d713de Mon Sep 17 00:00:00 2001 From: Zaba999 Date: Fri, 20 Jul 2012 23:13:02 +0200 Subject: Further translations and doxygen comments. --- src/CBot/CBot.cpp | 1827 +++++++++++++++++------------------- src/CBot/CBot.h | 2020 +++++++++++++++++++++------------------- src/CBot/CBotDll.h | 102 +- src/CBot/CBotFunction.cpp | 4 - src/CBot/CBotStack.cpp | 1707 +++++++++++++++++----------------- src/CBot/CBotString.cpp | 6 +- src/CBot/CBotVar.cpp | 2270 ++++++++++++++++++++++----------------------- src/CBot/resource.h | 2 - 8 files changed, 3957 insertions(+), 3981 deletions(-) (limited to 'src') diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp index e73eea0..fb25049 100644 --- a/src/CBot/CBot.cpp +++ b/src/CBot/CBot.cpp @@ -87,8 +87,8 @@ bool CBotInstr::ChkLvl(const CBotString& label, int type) while (--i>=0) { if ( type == ID_CONTINUE && m_labelLvl[i] == "#SWITCH") continue; - if ( label.IsEmpty() ) return true; - if ( m_labelLvl[i] == label ) return true; + if (label.IsEmpty()) return true; + if (m_labelLvl[i] == label) return true; } return false; } @@ -128,21 +128,21 @@ CBotToken* CBotInstr::GivToken() void CBotInstr::AddNext(CBotInstr* n) { CBotInstr* p = this; - while ( p->m_next != NULL ) p = p->m_next; + while (p->m_next != NULL) p = p->m_next; p->m_next = n; } void CBotInstr::AddNext3(CBotInstr* n) { CBotInstr* p = this; - while ( p->m_next3 != NULL ) p = p->m_next3; + while (p->m_next3 != NULL) p = p->m_next3; p->m_next3 = n; } void CBotInstr::AddNext3b(CBotInstr* n) { CBotInstr* p = this; - while ( p->m_next3b != NULL ) p = p->m_next3b; + while (p->m_next3b != NULL) p = p->m_next3b; p->m_next3b = n; } @@ -175,17 +175,17 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack) { CBotToken* pp = p; - if ( p == NULL ) return NULL; + if (p == NULL) return NULL; int type = p->GivType(); // what is the next token // is it a lable? - if ( IsOfType( pp, TokenTypVar ) && - IsOfType( pp, ID_DOTS ) ) + if (IsOfType(pp, TokenTypVar) && + IsOfType(pp, ID_DOTS)) { type = pp->GivType(); // these instructions accept only lable - if (!IsOfTypeList( pp, ID_WHILE, ID_FOR, ID_DO, ID_REPEAT, 0 )) + if (!IsOfTypeList(pp, ID_WHILE, ID_FOR, ID_DO, ID_REPEAT, 0)) { pStack->SetError(TX_LABEL, pp->GivStart()); return NULL; @@ -255,7 +255,7 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack) pStack->SetStartError(p->GivStart()); - // ne doit pas être un mot réservé par DefineNum + // should not be a reserved word DefineNum if (p->GivType() == TokenTypDef) { pStack->SetError(TX_RESERVED, p); @@ -264,16 +264,16 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack) // this might be an instance of class definnition CBotToken* ppp = p; - if (IsOfType( ppp, TokenTypVar )) + if (IsOfType(ppp, TokenTypVar)) { - if ( CBotClass::Find(p) != NULL ) + if (CBotClass::Find(p) != NULL) { - // oui, compile la déclaration de l'instance + // yes, compiles the declaration of the instance return CBotClassInst::Compile(p, pStack); } } - // ce peut être une instruction arithmétique + // this can be an arythmetic instruction CBotInstr* inst = CBotExpression::Compile(p, pStack); if (IsOfType(p, ID_SEP)) { @@ -287,46 +287,46 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack) bool CBotInstr::Execute(CBotStack* &pj) { CBotString ClassManquante = name; - ASM_TRAP(); // ne doit jamais passer par cette routine - // mais utiliser les routines des classes filles + ASM_TRAP(); // should never go through this routine + // but use the routines of the subclasses return false; } bool CBotInstr::Execute(CBotStack* &pj, CBotVar* pVar) { - if ( !Execute(pj) ) return false; - pVar->SetVal( pj->GivVar() ); + if (!Execute(pj)) return false; + pVar->SetVal(pj->GivVar()); return true; } void CBotInstr::RestoreState(CBotStack* &pj, bool bMain) { CBotString ClassManquante = name; - ASM_TRAP(); // ne doit jamais passer par cette routine - // mais utiliser les routines des classes filles + ASM_TRAP(); // should never go through this routine + // but use the routines of the subclasses } bool CBotInstr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) { - ASM_TRAP(); // papa sait pas faire, voir les filles + ASM_TRAP(); // dad do not know, see the girls return false; } bool CBotInstr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep, bool bExtend) { - ASM_TRAP(); // papa sait pas faire, voir les filles + ASM_TRAP(); // dad do not know, see the girls return false; } void CBotInstr::RestoreStateVar(CBotStack* &pile, bool bMain) { - ASM_TRAP(); // papa sait pas faire, voir les filles + ASM_TRAP(); // dad do not know, see the girls } -// cette routine n'est définie que pour la classe fille CBotCase -// cela permet de faire l'appel CompCase sur toutes les instructions -// pour savoir s'il s'agit d'un case pour la valeur désirée. +// this routine is defined only for the subclass CBotCase +// this allows to make the call on all instructions CompCase +// to see if it's a case to the desired value. bool CBotInstr::CompCase(CBotStack* &pj, int val) { @@ -337,10 +337,11 @@ bool CBotInstr::CompCase(CBotStack* &pj, int val) ////////////////////////////////////////////////////////////////////////////////////// -// compile un bloc d'instruction " { i ; i ; } " +// compiles a statement block " { i ; i ; } " -// cette classe n'a pas de constructeur, car il n'y a jamais d'instance de cette classe -// l'objet retourné par Compile est généralement de type CBotListInstr +// this class have no constructor because there is never an instance of this +// class (TODO what about default constructor?) +// the object returned by Compile is usually of type CBotListInstr CBotInstr* CBotBlock::Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal) @@ -349,14 +350,14 @@ CBotInstr* CBotBlock::Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal) if (IsOfType(p, ID_OPBLK)) { - CBotInstr* inst = CBotListInstr::Compile( p, pStack, bLocal ); + CBotInstr* inst = CBotListInstr::Compile(p, pStack, bLocal); if (IsOfType(p, ID_CLBLK)) { return inst; } - pStack->SetError(TX_CLOSEBLK, p->GivStart()); // manque la parenthèse + pStack->SetError(TX_CLOSEBLK, p->GivStart()); // missing parenthesis delete inst; return NULL; } @@ -367,28 +368,28 @@ CBotInstr* CBotBlock::Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal) CBotInstr* CBotBlock::CompileBlkOrInst(CBotToken* &p, CBotCStack* pStack, bool bLocal) { - // est-ce un nouveau bloc ? - if ( p->GivType() == ID_OPBLK ) return CBotBlock::Compile(p, pStack); + // is this a new block + if (p->GivType() == ID_OPBLK) return CBotBlock::Compile(p, pStack); - // sinon, cherche une instruction unique à la place + // otherwise, look for a single statement instead - // pour gérer les cas avec définition local à l'instructin (*) + // to handle the case with local definition instruction (*) CBotCStack* pStk = pStack->TokenStack(p, bLocal); - return pStack->Return( CBotInstr::Compile(p, pStk), // une instruction unique + return pStack->Return( CBotInstr::Compile(p, pStk), // a single instruction pStk); } -// (*) c'est le cas dans l'instruction suivante -// if ( 1 == 1 ) int x = 0; -// où la variable x n'est connue que dans le bloc qui suit le if. +// (*) is the case in the following statement +// if (1 == 1) int x = 0; +// where the variable x is known only in the block following the if ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// -// compile une liste d'instruction, séparés par des points-virgules +// compiles a list of instructions separated by semicolons CBotListInstr::CBotListInstr() { @@ -403,16 +404,16 @@ CBotListInstr::~CBotListInstr() CBotInstr* CBotListInstr::Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal) { - CBotCStack* pStk = pStack->TokenStack(p, bLocal); // les variables sont locales + CBotCStack* pStk = pStack->TokenStack(p, bLocal); // variables are local CBotListInstr* inst = new CBotListInstr(); while (true) { - if ( p == NULL ) break; + if (p == NULL) break; - if (IsOfType(p, ID_SEP)) continue; // instruction vide ignorée - if ( p->GivType() == ID_CLBLK ) break; // déja plus d'instruction + if (IsOfType(p, ID_SEP)) continue; // empty statement ignored + if (p->GivType() == ID_CLBLK) break; if (IsOfType(p, 0)) { @@ -421,7 +422,7 @@ CBotInstr* CBotListInstr::Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal return pStack->Return(NULL, pStk); } - CBotInstr* i = CBotBlock::CompileBlkOrInst( p, pStk ); // compile la suivante + CBotInstr* i = CBotBlock::CompileBlkOrInst(p, pStk); // compiles next if (!pStk->IsOk()) { @@ -429,62 +430,60 @@ CBotInstr* CBotListInstr::Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal return pStack->Return(NULL, pStk); } - if ( inst->m_Instr == NULL ) inst->m_Instr = i; - else inst->m_Instr->AddNext(i); // ajoute à la suite + if (inst->m_Instr == NULL) inst->m_Instr = i; + else inst->m_Instr->AddNext(i); // added a result } return pStack->Return(inst, pStk); } -// exécute une liste d'instructions +// executes a set of instructions bool CBotListInstr::Execute(CBotStack* &pj) { - CBotStack* pile = pj->AddStack(this, true);//indispensable pour SetState() - if ( pile->StackOver() ) return pj->Return( pile ); + CBotStack* pile = pj->AddStack(this, true); //needed for SetState() + if (pile->StackOver() ) return pj->Return( pile); - CBotInstr* p = m_Instr; // la première expression + CBotInstr* p = m_Instr; // the first expression int state = pile->GivState(); - while (state-->0) p = p->GivNext(); // revient sur l'opération interrompue + while (state-->0) p = p->GivNext(); // returns to the interrupted operation - if ( p != NULL ) while (true) + if (p != NULL) while (true) { -// DEBUG( "CBotListInstr", pile->GivState(), pile ); - - if ( !p->Execute(pile) ) return false; + if (!p->Execute(pile)) return false; p = p->GivNext(); - if ( p == NULL ) break; - if (!pile->IncState()) ;//return false; // prêt pour la suivante + if (p == NULL) break; + if (!pile->IncState()) ;//return false; // ready for next } - return pj->Return( pile ); // transmet en dessous + return pj->Return(pile); } void CBotListInstr::RestoreState(CBotStack* &pj, bool bMain) { - if ( !bMain ) return; + if (!bMain) return; CBotStack* pile = pj->RestoreStack(this); - if ( pile == NULL ) return; + if (pile == NULL) return; - CBotInstr* p = m_Instr; // la première expression + CBotInstr* p = m_Instr; // the first expression int state = pile->GivState(); while ( p != NULL && state-- > 0) { p->RestoreState(pile, false); - p = p->GivNext(); // revient sur l'opération interrompue + p = p->GivNext(); // returns to the interrupted operation } - if ( p != NULL ) p->RestoreState(pile, true); + if (p != NULL) p->RestoreState(pile, true); } ////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// -// compilation d'un élément se trouvant à gauche d'une assignation +// compilation of an element to the left of an assignment CBotLeftExprVar::CBotLeftExprVar() { @@ -499,7 +498,7 @@ CBotLeftExprVar::~CBotLeftExprVar() CBotInstr* CBotLeftExprVar::Compile(CBotToken* &p, CBotCStack* pStack) { - // vérifie que le token est un nom de variable + // verifies that the token is a variable name if (p->GivType() != TokenTypVar) { pStack->SetError( TX_NOVAR, p->GivStart()); @@ -513,20 +512,20 @@ CBotInstr* CBotLeftExprVar::Compile(CBotToken* &p, CBotCStack* pStack) return inst; } -// crée une variable et lui assigne le résultat de la pile +// creates a variable and assigns the result to the stack bool CBotLeftExprVar::Execute(CBotStack* &pj) { CBotVar* var1; CBotVar* var2; var1 = CBotVar::Create(m_token.GivString(), m_typevar); - var1->SetUniqNum(m_nIdent); // avec cet identificateur unique - pj->AddVar(var1); // la place sur la pile - - var2 = pj->GivVar(); // resultat sur la pile - if ( var2 ) var1->SetVal(var2); // fait l'assignation + var1->SetUniqNum(m_nIdent); // with the unique identifier + pj->AddVar(var1); // place it on the stack + + var2 = pj->GivVar(); // result on the stack + if (var2) var1->SetVal(var2); // do the assignment - return true; // opération faite + return true; } void CBotLeftExprVar::RestoreState(CBotStack* &pj, bool bMain) @@ -534,9 +533,9 @@ void CBotLeftExprVar::RestoreState(CBotStack* &pj, bool bMain) CBotVar* var1; var1 = pj->FindVar(m_token.GivString()); - if ( var1 == NULL ) ASM_TRAP(); + if (var1 == NULL) ASM_TRAP(); - var1->SetUniqNum(m_nIdent); // avec cet identificateur unique + var1->SetUniqNum(m_nIdent); // with the unique identifier } ////////////////////////////////////////////////////////////////////////////////////// @@ -544,7 +543,7 @@ void CBotLeftExprVar::RestoreState(CBotStack* &pj, bool bMain) ////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// -// définition d'un tableau de n'importe quel type +// defining an array of any type // int a[12]; // point x[]; @@ -566,52 +565,51 @@ CBotInstr* CBotInstArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResu { CBotCStack* pStk = pStack->TokenStack(p); - CBotInstArray* inst = new CBotInstArray(); // crée l'objet + CBotInstArray* inst = new CBotInstArray(); CBotToken* vartoken = p; inst->SetToken(vartoken); - // détermine l'expression valable pour l'élément gauche - if ( NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )) ) + // determinse the expression is valid for the item on the left side + if (NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk ))) { - if (pStk->CheckVarLocal(vartoken)) // redéfinition de la variable ? + if (pStk->CheckVarLocal(vartoken)) // redefinition of the variable? { pStk->SetError(TX_REDEFVAR, vartoken); goto error; } CBotInstr* i; - while (IsOfType(p, ID_OPBRK)) // avec des indices ? + while (IsOfType(p, ID_OPBRK)) { - if ( p->GivType() != ID_CLBRK ) - i = CBotExpression::Compile( p, pStk ); // expression pour la valeur + if (p->GivType() != ID_CLBRK) + i = CBotExpression::Compile(p, pStk); // expression for the value else - i = new CBotEmpty(); // spécial si pas de formule + i = new CBotEmpty(); // if no special formula - inst->AddNext3b(i); // construit une liste + inst->AddNext3b(i); // construct a list type = CBotTypResult(CBotTypArrayPointer, type); - if (!pStk->IsOk() || !IsOfType( p, ID_CLBRK ) ) + if (!pStk->IsOk() || !IsOfType(p, ID_CLBRK )) { pStk->SetError(TX_CLBRK, p->GivStart()); goto error; } } - CBotVar* var = CBotVar::Create(vartoken, type); // crée avec une instance + CBotVar* var = CBotVar::Create(vartoken, type); // create an instance inst->m_typevar = type; var->SetUniqNum( ((CBotLeftExprVar*)inst->m_var)->m_nIdent = CBotVar::NextUniqNum()); - // lui attribut un numéro unique - pStack->AddVar(var); // la place sur la pile + pStack->AddVar(var); // place it on the stack - if ( IsOfType(p, ID_ASS) ) // avec une assignation + if (IsOfType(p, ID_ASS)) // with an assignment { - inst->m_listass = CBotListArray::Compile( p, pStk, type.GivTypElem() ); + inst->m_listass = CBotListArray::Compile(p, pStk, type.GivTypElem()); } - if ( pStk->IsOk() ) return pStack->Return(inst, pStk); + if (pStk->IsOk()) return pStack->Return(inst, pStk); } error: @@ -620,86 +618,85 @@ error: } -// exécute la définition d'un tableau +// executes the definition of an array bool CBotInstArray::Execute(CBotStack* &pj) { CBotStack* pile1 = pj->AddStack(this); -// if ( pile1 == EOX ) return true; CBotStack* pile = pile1; - if ( pile1->GivState() == 0 ) + if (pile1->GivState() == 0) { - // cherche les dimensions max du tableau - CBotInstr* p = GivNext3b(); // les différentes formules + // seek the maximum dimension of the table + CBotInstr* p = GivNext3b(); // the different formulas int nb = 0; while (p != NULL) { - pile = pile->AddStack(); // petite place pour travailler + pile = pile->AddStack(); // little room to work nb++; - if ( pile->GivState() == 0 ) + if (pile->GivState() == 0) { - if ( !p->Execute(pile) ) return false; // calcul de la taille // interrompu? + if (!p->Execute(pile)) return false; // size calculation //interrupted? pile->IncState(); } p = p->GivNext3b(); } p = GivNext3b(); - pile = pile1; // revient sur la pile + pile = pile1; // returns to the stack int n = 0; int max[100]; while (p != NULL) { - pile = pile->AddStack(); // récupère la même petite place - CBotVar* v = pile->GivVar(); // résultat - max[n] = v->GivValInt(); // valeur + pile = pile->AddStack(); + CBotVar* v = pile->GivVar(); // result + max[n] = v->GivValInt(); // value if (max[n]>MAXARRAYSIZE) { pile->SetError(TX_OUTARRAY, &m_token); - return pj->Return ( pile ); + return pj->Return (pile); } n++; p = p->GivNext3b(); } while (n<100) max[n++] = 0; - m_typevar.SetArray( max ); // mémorise les limitations + m_typevar.SetArray(max); // store the limitations // crée simplement un pointeur null CBotVar* var = CBotVar::Create(m_var->GivToken(), m_typevar); var->SetPointer(NULL); var->SetUniqNum(((CBotLeftExprVar*)m_var)->m_nIdent); - pj->AddVar(var); // inscrit le tableau de base sur la pile + pj->AddVar(var); #if STACKMEM pile1->AddStack()->Delete(); #else - delete pile1->AddStack(); // plus besoin des indices + delete pile1->AddStack(); // need more indices #endif pile1->IncState(); } - if ( pile1->GivState() == 1 ) + if (pile1->GivState() == 1) { - if ( m_listass != NULL ) // il y a des assignation pour ce tableau + if (m_listass != NULL) // there is the assignment for this table { CBotVar* pVar = pj->FindVar(((CBotLeftExprVar*)m_var)->m_nIdent); - if ( !m_listass->Execute(pile1, pVar) ) return false; + if (!m_listass->Execute(pile1, pVar)) return false; } pile1->IncState(); } - if ( pile1->IfStep() ) return false; // montre ce pas ? + if (pile1->IfStep()) return false; if ( m_next2b && - !m_next2b->Execute( pile1 ) ) return false; + !m_next2b->Execute(pile1 )) return false; - return pj->Return( pile1 ); // transmet en dessous + return pj->Return(pile1); } void CBotInstArray::RestoreState(CBotStack* &pj, bool bMain) @@ -707,47 +704,46 @@ void CBotInstArray::RestoreState(CBotStack* &pj, bool bMain) CBotStack* pile1 = pj; CBotVar* var = pj->FindVar(m_var->GivToken()->GivString()); - if ( var != NULL ) var->SetUniqNum(((CBotLeftExprVar*)m_var)->m_nIdent); + if (var != NULL) var->SetUniqNum(((CBotLeftExprVar*)m_var)->m_nIdent); - if ( bMain ) + if (bMain) { - pile1 = pj->RestoreStack(this); + pile1 = pj->RestoreStack(this); CBotStack* pile = pile1; - if ( pile == NULL ) return; + if (pile == NULL) return; - if ( pile1->GivState() == 0 ) + if (pile1->GivState() == 0) { - // cherche les dimensions max du tableau - CBotInstr* p = GivNext3b(); // les différentes formules + // seek the maximum dimension of the table + CBotInstr* p = GivNext3b(); while (p != NULL) { - pile = pile->RestoreStack(); // petite place pour travailler - if ( pile == NULL ) return; - if ( pile->GivState() == 0 ) + pile = pile->RestoreStack(); + if (pile == NULL) return; + if (pile->GivState() == 0) { - p->RestoreState(pile, bMain); // calcul de la taille // interrompu! + p->RestoreState(pile, bMain); return; } p = p->GivNext3b(); } } - if ( pile1->GivState() == 1 && m_listass != NULL ) + if (pile1->GivState() == 1 && m_listass != NULL) { m_listass->RestoreState(pile1, bMain); } } - - if ( m_next2b ) m_next2b->RestoreState( pile1, bMain ); + if (m_next2b ) m_next2b->RestoreState( pile1, bMain); } -// cas particulier pour les indices vides +// special case for empty indexes bool CBotEmpty :: Execute(CBotStack* &pj) { CBotVar* pVar = CBotVar::Create("", CBotTypInt); - pVar->SetValInt(-1); // met la valeur -1 sur la pile + pVar->SetValInt(-1); pj->SetVar(pVar); return true; } @@ -757,8 +753,8 @@ void CBotEmpty :: RestoreState(CBotStack* &pj, bool bMain) } ////////////////////////////////////////////////////////////////////////////////////// -// définition d'une liste d'initialisation pour un tableau -// int [ ] a [ ] = ( ( 1, 2, 3 ) , ( 3, 2, 1 ) ) ; +// defining a list table initialization +// int [ ] a [ ] = (( 1, 2, 3 ) , ( 3, 2, 1 )) ; CBotListArray::CBotListArray() @@ -779,36 +775,34 @@ CBotInstr* CBotListArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResu CBotToken* pp = p; - if ( IsOfType( p, ID_NULL ) ) + if (IsOfType( p, ID_NULL )) { CBotInstr* inst = new CBotExprNull (); - inst->SetToken( pp ); -// CBotVar* var = CBotVar::Create("", CBotTypNullPointer); -// pStk->SetVar(var); - return pStack->Return(inst, pStk); // ok avec élément vide + inst->SetToken(pp); + return pStack->Return(inst, pStk); // ok with empty element } - CBotListArray* inst = new CBotListArray(); // crée l'objet + CBotListArray* inst = new CBotListArray(); - if ( IsOfType( p, ID_OPENPAR ) ) + if (IsOfType( p, ID_OPENPAR )) { - // prend chaque élément l'un après l'autre - if ( type.Eq( CBotTypArrayPointer ) ) + // each element takes the one after the other + if (type.Eq( CBotTypArrayPointer )) { type = type.GivTypElem(); pStk->SetStartError(p->GivStart()); - if ( NULL == ( inst->m_expr = CBotListArray::Compile( p, pStk, type ) ) ) + if (NULL == ( inst->m_expr = CBotListArray::Compile( p, pStk, type ) )) { goto error; } - while ( IsOfType( p, ID_COMMA ) ) // d'autres éléments ? + while (IsOfType( p, ID_COMMA )) // other elements? { pStk->SetStartError(p->GivStart()); - CBotInstr* i = CBotListArray::Compile( p, pStk, type ); - if ( NULL == i ) + CBotInstr* i = CBotListArray::Compile(p, pStk, type); + if (NULL == i) { goto error; } @@ -819,31 +813,31 @@ CBotInstr* CBotListArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResu else { pStk->SetStartError(p->GivStart()); - if ( NULL == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk )) ) + if (NULL == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk ))) { goto error; } - CBotVar* pv = pStk->GivVar(); // le résultat de l'expression + CBotVar* pv = pStk->GivVar(); // result of the expression - if ( pv == NULL || !TypesCompatibles( type, pv->GivTypResult() )) // type compatible ? + if (pv == NULL || !TypesCompatibles( type, pv->GivTypResult())) // compatible type? { pStk->SetError(TX_BADTYPE, p->GivStart()); goto error; } - while ( IsOfType( p, ID_COMMA ) ) // d'autres éléments ? + while (IsOfType( p, ID_COMMA )) // other elements? { pStk->SetStartError(p->GivStart()); - CBotInstr* i = CBotTwoOpExpr::Compile( p, pStk ) ; - if ( NULL == i ) + CBotInstr* i = CBotTwoOpExpr::Compile(p, pStk) ; + if (NULL == i) { goto error; } - CBotVar* pv = pStk->GivVar(); // le résultat de l'expression + CBotVar* pv = pStk->GivVar(); // result of the expression - if ( pv == NULL || !TypesCompatibles( type, pv->GivTypResult() )) // type compatible ? + if (pv == NULL || !TypesCompatibles( type, pv->GivTypResult())) // compatible type? { pStk->SetError(TX_BADTYPE, p->GivStart()); goto error; @@ -867,58 +861,57 @@ error: } -// exécute la définition d'un tableau +// executes the definition of an array bool CBotListArray::Execute(CBotStack* &pj, CBotVar* pVar) { CBotStack* pile1 = pj->AddStack(); -// if ( pile1 == EOX ) return true; CBotVar* pVar2; CBotInstr* p = m_expr; int n = 0; - for ( ; p != NULL ; n++, p = p->GivNext3() ) + for (; p != NULL ; n++, p = p->GivNext3()) { - if ( pile1->GivState() > n ) continue; + if (pile1->GivState() > n) continue; pVar2 = pVar->GivItem(n, true); - if ( !p->Execute(pile1, pVar2) ) return false; // évalue l'expression + if (!p->Execute(pile1, pVar2)) return false; // evaluate expression pile1->IncState(); } - return pj->Return( pile1 ); // transmet en dessous + return pj->Return(pile1); } void CBotListArray::RestoreState(CBotStack* &pj, bool bMain) { - if ( bMain ) + if (bMain) { CBotStack* pile = pj->RestoreStack(this); - if ( pile == NULL ) return; + if (pile == NULL) return; CBotInstr* p = m_expr; int state = pile->GivState(); - while( state-- > 0 ) p = p->GivNext3() ; + while(state-- > 0) p = p->GivNext3() ; - p->RestoreState(pile, bMain); // calcul de la taille // interrompu! + p->RestoreState(pile, bMain); // size calculation //interrupted! } } ////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// -// définition d'une variable entière +// definition of an integer variable // int a, b = 12; CBotInt::CBotInt() { - m_next = NULL; // pour les définitions multiples + m_next = NULL; // for multiple definitions m_var = m_expr = NULL; name = "CBotInt"; @@ -928,32 +921,31 @@ CBotInt::~CBotInt() { delete m_var; delete m_expr; -// delete m_next; // fait par le destructeur de la classe de base ~CBotInstr() } CBotInstr* CBotInstr::CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypResult type, bool first) { - if ( IsOfType(p, ID_OPBRK) ) + if (IsOfType(p, ID_OPBRK)) { - if ( !IsOfType(p, ID_CLBRK) ) + if (!IsOfType(p, ID_CLBRK)) { pStack->SetError(TX_CLBRK, p->GivStart()); return NULL; } - CBotInstr* inst = CompileArray(p, pStack, CBotTypResult( CBotTypArrayPointer, type ), false); - if ( inst != NULL || !pStack->IsOk() ) return inst; + CBotInstr* inst = CompileArray(p, pStack, CBotTypResult(CBotTypArrayPointer, type), false); + if (inst != NULL || !pStack->IsOk()) return inst; } - // compile une déclaration de tableau + // compiles an array declaration if (first) return NULL ; - CBotInstr* inst = CBotInstArray::Compile( p, pStack, type ); - if ( inst == NULL ) return NULL; + CBotInstr* inst = CBotInstArray::Compile(p, pStack, type); + if (inst == NULL) return NULL; - if (IsOfType(p, ID_COMMA)) // plusieurs définitions enchaînées + if (IsOfType(p, ID_COMMA)) // several definitions { - if ( NULL != ( inst->m_next2b = CBotInstArray::CompileArray(p, pStack, type, false) )) // compile la suivante + if (NULL != ( inst->m_next2b = CBotInstArray::CompileArray(p, pStack, type, false))) // compiles next one { return inst; } @@ -961,7 +953,7 @@ CBotInstr* CBotInstr::CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypRes return NULL; } - if (IsOfType(p, ID_SEP)) // instruction terminée + if (IsOfType(p, ID_SEP)) // end of instruction { return inst; } @@ -973,40 +965,40 @@ CBotInstr* CBotInstr::CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypRes CBotInstr* CBotInt::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool noskip) { - CBotToken* pp = cont ? NULL : p; // pas de répétition du token "int" + CBotToken* pp = cont ? NULL : p; // no repetition of the token "int" if (!cont && !IsOfType(p, ID_INT)) return NULL; CBotInt* inst = (CBotInt*)CompileArray(p, pStack, CBotTypInt); - if ( inst != NULL || !pStack->IsOk() ) return inst; + if (inst != NULL || !pStack->IsOk()) return inst; CBotCStack* pStk = pStack->TokenStack(pp); - inst = new CBotInt(); // crée l'objet + inst = new CBotInt(); inst->m_expr = NULL; CBotToken* vartoken = p; - inst->SetToken( vartoken ); + inst->SetToken(vartoken); - // détermine l'expression valable pour l'élément gauche - if ( NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )) ) + // determines the expression is valid for the item on the left side + if (NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk ))) { ((CBotLeftExprVar*)inst->m_var)->m_typevar = CBotTypInt; - if (pStk->CheckVarLocal(vartoken)) // redéfinition de la variable + if (pStk->CheckVarLocal(vartoken)) // redefinition of the variable { pStk->SetError(TX_REDEFVAR, vartoken); goto error; } - if (IsOfType(p, ID_OPBRK)) // avec des indices ? + if (IsOfType(p, ID_OPBRK)) { - delete inst; // n'est pas de type CBotInt - p = vartoken; // revient sur le nom de la variable + delete inst; // type is not CBotInt + p = vartoken; // returns the variable name - // compile une déclaration de tableau + // compiles an array declaration - CBotInstr* inst2 = CBotInstArray::Compile( p, pStk, CBotTypInt ); + CBotInstr* inst2 = CBotInstArray::Compile(p, pStk, CBotTypInt); if (!pStk->IsOk() ) { @@ -1014,24 +1006,24 @@ CBotInstr* CBotInt::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool n goto error; } - if (IsOfType(p, ID_COMMA)) // plusieurs définitions enchaînées + if (IsOfType(p, ID_COMMA)) // several definition chained { - if ( NULL != ( inst2->m_next2b = CBotInt::Compile(p, pStk, true, noskip) )) // compile la suivante + if (NULL != ( inst2->m_next2b = CBotInt::Compile(p, pStk, true, noskip))) // compile the next one { return pStack->Return(inst2, pStk); } } inst = (CBotInt*)inst2; - goto suite; // pas d'assignation, variable déjà créée + goto suite; // no assignment, variable already created } - if (IsOfType(p, ID_ASS)) // avec une assignation ? + if (IsOfType(p, ID_ASS)) // with an assignment? { - if ( NULL == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk )) ) + if (NULL == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk ))) { goto error; } - if ( pStk->GivType() >= CBotTypBoolean ) // type compatible ? + if (pStk->GivType() >= CBotTypBoolean) // compatible type ? { pStk->SetError(TX_BADTYPE, p->GivStart()); goto error; @@ -1039,23 +1031,22 @@ CBotInstr* CBotInt::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool n } { - CBotVar* var = CBotVar::Create(vartoken, CBotTypInt);// crée la variable (après l'assignation évaluée) - var->SetInit(inst->m_expr != NULL); // la marque initialisée si avec assignation - var->SetUniqNum( + CBotVar* var = CBotVar::Create(vartoken, CBotTypInt);// create the variable (evaluated after the assignment) + var->SetInit(inst->m_expr != NULL); // if initialized with assignment + var->SetUniqNum( //set it with a unique number ((CBotLeftExprVar*)inst->m_var)->m_nIdent = CBotVar::NextUniqNum()); - // lui attribut un numéro unique - pStack->AddVar(var); // la place sur la pile + pStack->AddVar(var); // place it on the stack } - if (IsOfType(p, ID_COMMA)) // plusieurs définitions enchaînées + if (IsOfType(p, ID_COMMA)) // chained several definitions { - if ( NULL != ( inst->m_next2b = CBotInt::Compile(p, pStk, true, noskip) )) // compile la suivante + if (NULL != ( inst->m_next2b = CBotInt::Compile(p, pStk, true, noskip))) // compile next one { return pStack->Return(inst, pStk); } } suite: - if (noskip || IsOfType(p, ID_SEP)) // instruction terminée + if (noskip || IsOfType(p, ID_SEP)) // instruction is completed { return pStack->Return(inst, pStk); } @@ -1068,54 +1059,53 @@ error: return pStack->Return(NULL, pStk); } -// exécute la définition de la variable entière +// execute the definition of the integer variable bool CBotInt::Execute(CBotStack* &pj) { - CBotStack* pile = pj->AddStack(this); //indispensable pour SetState() -// if ( pile == EOX ) return true; + CBotStack* pile = pj->AddStack(this); // essential for SetState() if ( pile->GivState()==0) { - if (m_expr && !m_expr->Execute(pile)) return false; // valeur initiale // interrompu? - m_var->Execute( pile ); // crée et fait l'assigation du résultat + if (m_expr && !m_expr->Execute(pile)) return false; // initial value // interrupted? + m_var->Execute(pile); // creates and assign the result if (!pile->SetState(1)) return false; } - if ( pile->IfStep() ) return false; + if (pile->IfStep()) return false; if ( m_next2b && - !m_next2b->Execute(pile)) return false; // autre(s) définition(s) + !m_next2b->Execute(pile)) return false; // other(s) definition(s) - return pj->Return( pile ); // transmet en dessous + return pj->Return(pile); // forward below } void CBotInt::RestoreState(CBotStack* &pj, bool bMain) { CBotStack* pile = pj; - if ( bMain ) + if (bMain) { pile = pj->RestoreStack(this); - if ( pile == NULL ) return; + if (pile == NULL) return; if ( pile->GivState()==0) { - if (m_expr) m_expr->RestoreState(pile, bMain); // valeur initiale // interrompu! + if (m_expr) m_expr->RestoreState(pile, bMain); // initial value // interrupted? return; } } m_var->RestoreState(pile, bMain); - if ( m_next2b ) m_next2b->RestoreState(pile, bMain); // autre(s) définition(s) + if (m_next2b) m_next2b->RestoreState(pile, bMain); // other(s) definition(s) } ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// -// définition d'une variable booléen +// defining a boolean variable // int a, b = false; CBotBoolean::CBotBoolean() @@ -1138,7 +1128,7 @@ CBotInstr* CBotBoolean::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bo if (!cont && !IsOfType(p, ID_BOOLEAN, ID_BOOL)) return NULL; CBotBoolean* inst = (CBotBoolean*)CompileArray(p, pStack, CBotTypBoolean); - if ( inst != NULL || !pStack->IsOk() ) return inst; + if (inst != NULL || !pStack->IsOk()) return inst; CBotCStack* pStk = pStack->TokenStack(pp); @@ -1147,64 +1137,63 @@ CBotInstr* CBotBoolean::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bo inst->m_expr = NULL; CBotToken* vartoken = p; - inst->SetToken( vartoken ); + inst->SetToken(vartoken); CBotVar* var = NULL; - if ( NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )) ) + if (NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk ))) { ((CBotLeftExprVar*)inst->m_var)->m_typevar = CBotTypBoolean; - if (pStk->CheckVarLocal(vartoken)) // redéfinition de la variable + if (pStk->CheckVarLocal(vartoken)) // redefinition of the variable { pStk->SetError(TX_REDEFVAR, vartoken); goto error; } - if (IsOfType(p, ID_OPBRK)) // avec des indices ? + if (IsOfType(p, ID_OPBRK)) { - delete inst; // n'est pas de type CBotInt - p = vartoken; // revient sur le nom de la variable + delete inst; // type is not CBotInt + p = vartoken; // resutns to the variable name - // compile une déclaration de tableau + // compiles an array declaration - inst = (CBotBoolean*)CBotInstArray::Compile( p, pStk, CBotTypBoolean ); + inst = (CBotBoolean*)CBotInstArray::Compile(p, pStk, CBotTypBoolean); if (!pStk->IsOk() ) { pStk->SetError(TX_CLBRK, p->GivStart()); goto error; } - goto suite; // pas d'assignation, variable déjà créée + goto suite; // no assignment, variable already created } - if (IsOfType(p, ID_ASS)) // avec une assignation ? + if (IsOfType(p, ID_ASS)) { - if ( NULL == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk )) ) + if (NULL == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk ))) { goto error; } - if ( !pStk->GivTypResult().Eq(CBotTypBoolean) ) // type compatible ? + if (!pStk->GivTypResult().Eq(CBotTypBoolean)) { pStk->SetError(TX_BADTYPE, p->GivStart()); goto error; } } - var = CBotVar::Create(vartoken, CBotTypBoolean);// crée la variable (après l'assignation évaluée) - var->SetInit(inst->m_expr != NULL); // la marque initialisée si avec assignation + var = CBotVar::Create(vartoken, CBotTypBoolean);// create the variable (evaluated after the assignment) + var->SetInit(inst->m_expr != NULL); var->SetUniqNum( ((CBotLeftExprVar*)inst->m_var)->m_nIdent = CBotVar::NextUniqNum()); - // lui attribut un numéro unique - pStack->AddVar(var); // la place sur la pile + pStack->AddVar(var); suite: - if (IsOfType(p, ID_COMMA)) // plusieurs définitions enchaînées + if (IsOfType(p, ID_COMMA)) { - if ( NULL != ( inst->m_next2b = CBotBoolean::Compile(p, pStk, true, noskip) )) // compile la suivante + if (NULL != ( inst->m_next2b = CBotBoolean::Compile(p, pStk, true, noskip))) { return pStack->Return(inst, pStk); } } - if (noskip || IsOfType(p, ID_SEP)) // instruction terminée + if (noskip || IsOfType(p, ID_SEP)) { return pStack->Return(inst, pStk); } @@ -1217,55 +1206,54 @@ error: return pStack->Return(NULL, pStk); } -// exécute une définition de variable booléenne +// executes a boolean variable definition bool CBotBoolean::Execute(CBotStack* &pj) { - CBotStack* pile = pj->AddStack(this);//indispensable pour SetState() -// if ( pile == EOX ) return true; + CBotStack* pile = pj->AddStack(this);//essential for SetState() if ( pile->GivState()==0) { - if (m_expr && !m_expr->Execute(pile)) return false; // valeur initiale // interrompu? - m_var->Execute( pile ); // crée et fait l'assigation du résultat + if (m_expr && !m_expr->Execute(pile)) return false; + m_var->Execute(pile); if (!pile->SetState(1)) return false; } - if ( pile->IfStep() ) return false; + if (pile->IfStep()) return false; if ( m_next2b && - !m_next2b->Execute(pile)) return false; // autre(s) définition(s) + !m_next2b->Execute(pile)) return false; - return pj->Return( pile ); // transmet en dessous + return pj->Return(pile); } void CBotBoolean::RestoreState(CBotStack* &pj, bool bMain) { CBotStack* pile = pj; - if ( bMain ) + if (bMain) { pile = pj->RestoreStack(this); - if ( pile == NULL ) return; + if (pile == NULL) return; if ( pile->GivState()==0) { - if (m_expr) m_expr->RestoreState(pile, bMain); // valeur initiale interrompu? + if (m_expr) m_expr->RestoreState(pile, bMain); // initial value interrupted? return; } } - m_var->RestoreState( pile, bMain ); // + m_var->RestoreState(pile, bMain); - if ( m_next2b ) - m_next2b->RestoreState(pile, bMain); // autre(s) définition(s) + if (m_next2b) + m_next2b->RestoreState(pile, bMain); // other(s) definition(s) } ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// -// définition d'une variable réelle +// definition of a real/float variable // int a, b = 12.4; CBotFloat::CBotFloat() @@ -1288,7 +1276,7 @@ CBotInstr* CBotFloat::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool if (!cont && !IsOfType(p, ID_FLOAT)) return NULL; CBotFloat* inst = (CBotFloat*)CompileArray(p, pStack, CBotTypFloat); - if ( inst != NULL || !pStack->IsOk() ) return inst; + if (inst != NULL || !pStack->IsOk()) return inst; CBotCStack* pStk = pStack->TokenStack(pp); @@ -1300,62 +1288,58 @@ CBotInstr* CBotFloat::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool CBotVar* var = NULL; inst->SetToken(vartoken); - if ( NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )) ) + if (NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk ))) { ((CBotLeftExprVar*)inst->m_var)->m_typevar = CBotTypFloat; - if (pStk->CheckVarLocal(vartoken)) // redéfinition de la variable + if (pStk->CheckVarLocal(vartoken)) // redefinition of a variable { pStk->SetStartError(vartoken->GivStart()); pStk->SetError(TX_REDEFVAR, vartoken->GivEnd()); goto error; } - if (IsOfType(p, ID_OPBRK)) // avec des indices ? + if (IsOfType(p, ID_OPBRK)) { - delete inst; // n'est pas de type CBotInt - p = vartoken; // revient sur le nom de la variable - - // compile une déclaration de tableau - - inst = (CBotFloat*)CBotInstArray::Compile( p, pStk, CBotTypFloat ); + delete inst; + p = vartoken; + inst = (CBotFloat*)CBotInstArray::Compile(p, pStk, CBotTypFloat); if (!pStk->IsOk() ) { pStk->SetError(TX_CLBRK, p->GivStart()); goto error; } - goto suite; // pas d'assignation, variable déjà créée + goto suite; // no assignment, variable already created } - if (IsOfType(p, ID_ASS)) // avec une assignation ? + if (IsOfType(p, ID_ASS)) { - if ( NULL == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk )) ) + if (NULL == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk ))) { goto error; } - if ( pStk->GivType() >= CBotTypBoolean ) // type compatible ? + if (pStk->GivType() >= CBotTypBoolean) { pStk->SetError(TX_BADTYPE, p->GivStart()); goto error; } } - var = CBotVar::Create(vartoken, CBotTypFloat); // crée la variable (après l'assignation évaluée) - var->SetInit(inst->m_expr != NULL); // la marque initialisée si avec assignation + var = CBotVar::Create(vartoken, CBotTypFloat); + var->SetInit(inst->m_expr != NULL); var->SetUniqNum( ((CBotLeftExprVar*)inst->m_var)->m_nIdent = CBotVar::NextUniqNum()); - // lui attribut un numéro unique - pStack->AddVar(var); // la place sur la pile + pStack->AddVar(var); suite: - if (IsOfType(p, ID_COMMA)) // plusieurs définitions enchaînées + if (IsOfType(p, ID_COMMA)) { - if ( NULL != ( inst->m_next2b = CBotFloat::Compile(p, pStk, true, noskip) )) // compile la suivante + if (NULL != ( inst->m_next2b = CBotFloat::Compile(p, pStk, true, noskip))) { return pStack->Return(inst, pStk); } } - if (noskip || IsOfType(p, ID_SEP)) // instruction terminée + if (noskip || IsOfType(p, ID_SEP)) { return pStack->Return(inst, pStk); } @@ -1368,55 +1352,54 @@ error: return pStack->Return(NULL, pStk); } -// exécute la défintion de la variable réelle +// executes the definition of a real variable bool CBotFloat::Execute(CBotStack* &pj) { - CBotStack* pile = pj->AddStack(this);//indispensable pour SetState() -// if ( pile == EOX ) return true; + CBotStack* pile = pj->AddStack(this); if ( pile->GivState()==0) { - if (m_expr && !m_expr->Execute(pile)) return false; // valeur initiale // interrompu? - m_var->Execute( pile ); // crée et fait l'assigation du résultat + if (m_expr && !m_expr->Execute(pile)) return false; + m_var->Execute(pile); if (!pile->SetState(1)) return false; } - if ( pile->IfStep() ) return false; + if (pile->IfStep()) return false; if ( m_next2b && - !m_next2b->Execute(pile)) return false; // autre(s) définition(s) + !m_next2b->Execute(pile)) return false; - return pj->Return( pile ); // transmet en dessous + return pj->Return(pile); } void CBotFloat::RestoreState(CBotStack* &pj, bool bMain) { CBotStack* pile = pj; - if ( bMain ) + if (bMain) { pile = pj->RestoreStack(this); - if ( pile == NULL ) return; + if (pile == NULL) return; if ( pile->GivState()==0) { - if (m_expr) m_expr->RestoreState(pile, bMain); // valeur initiale interrompu? + if (m_expr) m_expr->RestoreState(pile, bMain); return; } } - m_var->RestoreState( pile, bMain ); // + m_var->RestoreState(pile, bMain); - if ( m_next2b ) - m_next2b->RestoreState(pile, bMain); // autre(s) définition(s) + if (m_next2b) + m_next2b->RestoreState(pile, bMain); } ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// -// définition d'une variable chaîne de caractères +// define a string variable // int a, b = "salut"; CBotIString::CBotIString() @@ -1439,7 +1422,7 @@ CBotInstr* CBotIString::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bo if (!cont && !IsOfType(p, ID_STRING)) return NULL; CBotIString* inst = (CBotIString*)CompileArray(p, pStack, CBotTypString); - if ( inst != NULL || !pStack->IsOk() ) return inst; + if (inst != NULL || !pStack->IsOk()) return inst; CBotCStack* pStk = pStack->TokenStack(pp); @@ -1448,47 +1431,46 @@ CBotInstr* CBotIString::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bo inst->m_expr = NULL; CBotToken* vartoken = p; - inst->SetToken( vartoken ); + inst->SetToken(vartoken); - if ( NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )) ) + if (NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk ))) { ((CBotLeftExprVar*)inst->m_var)->m_typevar = CBotTypString; - if (pStk->CheckVarLocal(vartoken)) // redéfinition de la variable + if (pStk->CheckVarLocal(vartoken)) { pStk->SetStartError(vartoken->GivStart()); pStk->SetError(TX_REDEFVAR, vartoken->GivEnd()); goto error; } - if (IsOfType(p, ID_ASS)) // avec une assignation ? + if (IsOfType(p, ID_ASS)) { - if ( NULL == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk )) ) + if (NULL == ( inst->m_expr = CBotTwoOpExpr::Compile( p, pStk ))) { goto error; } -/* if ( !pStk->GivTypResult().Eq(CBotTypString) ) // type compatible ? +/* if (!pStk->GivTypResult().Eq(CBotTypString)) // type compatible ? { pStk->SetError(TX_BADTYPE, p->GivStart()); goto error; }*/ } - CBotVar* var = CBotVar::Create(vartoken, CBotTypString); // crée la variable (après l'assignation évaluée) - var->SetInit(inst->m_expr != NULL); // la marque initialisée si avec assignation + CBotVar* var = CBotVar::Create(vartoken, CBotTypString); + var->SetInit(inst->m_expr != NULL); var->SetUniqNum( ((CBotLeftExprVar*)inst->m_var)->m_nIdent = CBotVar::NextUniqNum()); - // lui attribut un numéro unique - pStack->AddVar(var); // la place sur la pile + pStack->AddVar(var); - if (IsOfType(p, ID_COMMA)) // plusieurs définitions enchaînées + if (IsOfType(p, ID_COMMA)) { - if ( NULL != ( inst->m_next2b = CBotIString::Compile(p, pStk, true, noskip) )) // compile la suivante + if (NULL != ( inst->m_next2b = CBotIString::Compile(p, pStk, true, noskip))) { return pStack->Return(inst, pStk); } } - - if (noskip || IsOfType(p, ID_SEP)) // instruction terminée + + if (noskip || IsOfType(p, ID_SEP)) { return pStack->Return(inst, pStk); } @@ -1501,49 +1483,48 @@ error: return pStack->Return(NULL, pStk); } -// exécute la définition de la variable string +// executes the definition of the string variable bool CBotIString::Execute(CBotStack* &pj) { - CBotStack* pile = pj->AddStack(this);//indispensable pour SetState() -// if ( pile == EOX ) return true; + CBotStack* pile = pj->AddStack(this); if ( pile->GivState()==0) { - if (m_expr && !m_expr->Execute(pile)) return false; // valeur initiale // interrompu? - m_var->Execute( pile ); // crée et fait l'assigation du résultat + if (m_expr && !m_expr->Execute(pile)) return false; + m_var->Execute(pile); if (!pile->SetState(1)) return false; } - if ( pile->IfStep() ) return false; + if (pile->IfStep()) return false; if ( m_next2b && - !m_next2b->Execute(pile)) return false; // autre(s) définition(s) + !m_next2b->Execute(pile)) return false; - return pj->Return( pile ); // transmet en dessous + return pj->Return(pile); } void CBotIString::RestoreState(CBotStack* &pj, bool bMain) { CBotStack* pile = pj; - - if ( bMain ) + + if (bMain) { pile = pj->RestoreStack(this); - if ( pile == NULL ) return; + if (pile == NULL) return; if ( pile->GivState()==0) { - if (m_expr) m_expr->RestoreState(pile, bMain); // valeur initiale interrompu? + if (m_expr) m_expr->RestoreState(pile, bMain); return; } } - m_var->RestoreState( pile, bMain ); // + m_var->RestoreState(pile, bMain); - if ( m_next2b ) - m_next2b->RestoreState(pile, bMain); // autre(s) définition(s) + if (m_next2b) + m_next2b->RestoreState(pile, bMain); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -1551,8 +1532,8 @@ void CBotIString::RestoreState(CBotStack* &pj, bool bMain) ////////////////////////////////////////////////////////////////////////////////////// -// compile une instruction de type " x = 123 " ou " z * 5 + 4 " -// avec ou sans assignation donc +// compiles a statement such as " x = 123 " ou " z * 5 + 4 " +// with or without assignment CBotExpression::CBotExpression() { @@ -1583,7 +1564,7 @@ CBotInstr* CBotExpression::Compile(CBotToken* &p, CBotCStack* pStack) ID_ASSAND, ID_ASSXOR, ID_ASSOR, ID_ASSSL , ID_ASSSR, ID_ASSASR, 0 )) { - if ( inst->m_leftop == NULL ) + if (inst->m_leftop == NULL) { pStack->SetError(TX_BADLEFT, p->GivEnd()); delete inst; @@ -1599,10 +1580,10 @@ CBotInstr* CBotExpression::Compile(CBotToken* &p, CBotCStack* pStack) CBotTypResult type1 = pStack->GivTypResult(); - // récupère la variable pour la marquer assignée + // get the variable assigned to mark CBotVar* var = NULL; inst->m_leftop->ExecuteVar(var, pStack); - if ( var == NULL ) + if (var == NULL) { delete inst; return NULL; @@ -1617,18 +1598,18 @@ CBotInstr* CBotExpression::Compile(CBotToken* &p, CBotCStack* pStack) CBotTypResult type2 = var->GivTypResult(); - // quels sont les types acceptables ? + // what types are acceptable? switch (OpType) { case ID_ASS: - // if (type2 == CBotTypClass) type2 = -1; // pas de classe - if ( (type1.Eq(CBotTypPointer) && type2.Eq(CBotTypPointer) ) || + // if (type2 == CBotTypClass) type2 = -1; + if ((type1.Eq(CBotTypPointer) && type2.Eq(CBotTypPointer)) || (type1.Eq(CBotTypClass) && type2.Eq(CBotTypClass) ) ) { /* CBotClass* c1 = type1.GivClass(); CBotClass* c2 = type2.GivClass(); - if ( !c1->IsChildOf(c2) ) type2.SetType(-1); // pas la même classe -//- if ( !type1.Eq(CBotTypClass) ) var->SetPointer(pStack->GivVar()->GivPointer());*/ + if (!c1->IsChildOf(c2)) type2.SetType(-1); +//- if (!type1.Eq(CBotTypClass)) var->SetPointer(pStack->GivVar()->GivPointer());*/ var->SetInit(2); } else @@ -1637,46 +1618,43 @@ CBotInstr* CBotExpression::Compile(CBotToken* &p, CBotCStack* pStack) break; case ID_ASSADD: if (type2.Eq(CBotTypBoolean) || - type2.Eq(CBotTypPointer) ) type2 = -1; // nombres et chaines + type2.Eq(CBotTypPointer) ) type2 = -1; // numbers and strings break; case ID_ASSSUB: case ID_ASSMUL: case ID_ASSDIV: case ID_ASSMODULO: - if (type2.GivType() >= CBotTypBoolean) type2 = -1; // nombres uniquement + if (type2.GivType() >= CBotTypBoolean) type2 = -1; // numbers only break; } - if (!TypeCompatible( type1, type2, OpType )) + if (!TypeCompatible(type1, type2, OpType)) { pStack->SetError(TX_BADTYPE, &inst->m_token); delete inst; return NULL; } - return inst; // types compatibles ? + return inst; // compatible type? } delete inst; -// p = p->GivNext(); int start, end, error = pStack->GivError(start, end); - p = pp; // revient au début - pStack->SetError(0,0); // oublie l'erreur + p = pp; // returns to the top + pStack->SetError(0,0); // forget the error -// return CBotTwoOpExpr::Compile(p, pStack); // essaie sans assignation - CBotInstr* i = CBotTwoOpExpr::Compile(p, pStack); // essaie sans assignation - if ( i != NULL && error == TX_PRIVATE && p->GivType() == ID_ASS ) - pStack->ResetError( error, start, end ); + CBotInstr* i = CBotTwoOpExpr::Compile(p, pStack); // tries without assignment + if (i != NULL && error == TX_PRIVATE && p->GivType() == ID_ASS) + pStack->ResetError(error, start, end); return i; } -// exécute une expression avec assignation +// executes an expression with assignment bool CBotExpression::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return true; CBotToken* pToken = m_leftop->GivToken(); CBotVar* pVar = NULL; @@ -1686,33 +1664,30 @@ bool CBotExpression::Execute(CBotStack* &pj) bool IsInit = true; CBotVar* result = NULL; - // doit être fait avant pour les indices éventuels (pile peut être changée) - if ( !m_leftop->ExecuteVar(pVar, pile, NULL, false) ) return false; // variable avant évaluation de la valeur droite + // must be done before any indexes (stack can be changed) + if (!m_leftop->ExecuteVar(pVar, pile, NULL, false)) return false; // variable before accessing the value on the right -// DEBUG( "CBotExpression::Execute", -1, pj); if ( pile1->GivState()==0) { - pile1->SetCopyVar(pVar); // garde une copie sur la pile (si interrompu) + pile1->SetCopyVar(pVar); // keeps the copy on the stack (if interrupted) pile1->IncState(); } - CBotStack* pile2 = pile->AddStack(); // attention pile et surtout pas pile1 + CBotStack* pile2 = pile->AddStack(); if ( pile2->GivState()==0) { -// DEBUG( "CBotExpression::Execute", -2, pj); - if (m_rightop && !m_rightop->Execute(pile2)) return false; // valeur initiale // interrompu? + if (m_rightop && !m_rightop->Execute(pile2)) return false; // initial value // interrupted? pile2->IncState(); } - if ( pile1->GivState() == 1 ) + if (pile1->GivState() == 1) { -// DEBUG( "CBotExpression::Execute", -3, pj); - if ( m_token.GivType() != ID_ASS ) + if (m_token.GivType() != ID_ASS) { - pVar = pile1->GivVar(); // récupére si interrompu + pVar = pile1->GivVar(); // recovers if interrupted IsInit = pVar->GivInit(); - if ( IsInit == IS_NAN ) + if (IsInit == IS_NAN) { pile2->SetError(TX_OPNAN, m_leftop->GivToken()); return pj->Return(pile2); @@ -1720,57 +1695,57 @@ bool CBotExpression::Execute(CBotStack* &pj) result = CBotVar::Create("", pVar->GivTypResult(2)); } - switch ( m_token.GivType() ) + switch (m_token.GivType()) { case ID_ASS: break; case ID_ASSADD: - result->Add(pile1->GivVar(), pile2->GivVar()); // additionne - pile2->SetVar(result); // re-place le résultat + result->Add(pile1->GivVar(), pile2->GivVar()); + pile2->SetVar(result); break; case ID_ASSSUB: - result->Sub(pile1->GivVar(), pile2->GivVar()); // soustrait - pile2->SetVar(result); // re-place le résultat + result->Sub(pile1->GivVar(), pile2->GivVar()); + pile2->SetVar(result); break; case ID_ASSMUL: - result->Mul(pile1->GivVar(), pile2->GivVar()); // multiplie - pile2->SetVar(result); // re-place le résultat + result->Mul(pile1->GivVar(), pile2->GivVar()); + pile2->SetVar(result); break; case ID_ASSDIV: if (IsInit && - result->Div(pile1->GivVar(), pile2->GivVar())) // divise + result->Div(pile1->GivVar(), pile2->GivVar())) pile2->SetError(TX_DIVZERO, &m_token); - pile2->SetVar(result); // re-place le résultat + pile2->SetVar(result); break; case ID_ASSMODULO: if (IsInit && - result->Modulo(pile1->GivVar(), pile2->GivVar())) // reste de la division + result->Modulo(pile1->GivVar(), pile2->GivVar())) pile2->SetError(TX_DIVZERO, &m_token); - pile2->SetVar(result); // re-place le résultat + pile2->SetVar(result); break; case ID_ASSAND: - result->And(pile1->GivVar(), pile2->GivVar()); // multiplie - pile2->SetVar(result); // re-place le résultat + result->And(pile1->GivVar(), pile2->GivVar()); + pile2->SetVar(result); break; case ID_ASSXOR: result->XOr(pile1->GivVar(), pile2->GivVar()); - pile2->SetVar(result); // re-place le résultat + pile2->SetVar(result); break; case ID_ASSOR: result->Or(pile1->GivVar(), pile2->GivVar()); - pile2->SetVar(result); // re-place le résultat + pile2->SetVar(result); break; case ID_ASSSL: result->SL(pile1->GivVar(), pile2->GivVar()); - pile2->SetVar(result); // re-place le résultat + pile2->SetVar(result); break; case ID_ASSSR: result->SR(pile1->GivVar(), pile2->GivVar()); - pile2->SetVar(result); // re-place le résultat + pile2->SetVar(result); break; case ID_ASSASR: result->ASR(pile1->GivVar(), pile2->GivVar()); - pile2->SetVar(result); // re-place le résultat + pile2->SetVar(result); break; default: ASM_TRAP(); @@ -1781,41 +1756,39 @@ bool CBotExpression::Execute(CBotStack* &pj) pile1->IncState(); } -// DEBUG( "CBotExpression::Execute", -4, pj); - if ( !m_leftop->Execute( pile2, pile1 ) ) - return false; // crée et fait l'assigation du résultat + if (!m_leftop->Execute( pile2, pile1 )) + return false; - return pj->Return( pile2 ); // transmet en dessous + return pj->Return(pile2); } void CBotExpression::RestoreState(CBotStack* &pj, bool bMain) { - if ( bMain ) + if (bMain) { CBotToken* pToken = m_leftop->GivToken(); CBotVar* pVar = NULL; CBotStack* pile = pj->RestoreStack(this); - if ( pile == NULL ) return; + if (pile == NULL) return; CBotStack* pile1 = pile; - if ( pile1->GivState()==0) { - m_leftop->RestoreStateVar(pile, true); // variable avant évaluation de la valeur droite + m_leftop->RestoreStateVar(pile, true); return; } - m_leftop->RestoreStateVar(pile, false); // variable avant évaluation de la valeur droite + m_leftop->RestoreStateVar(pile, false); - CBotStack* pile2 = pile->RestoreStack(); // attention pile et surtout pas pile1 - if ( pile2 == NULL ) return; + CBotStack* pile2 = pile->RestoreStack(); + if (pile2 == NULL) return; if ( pile2->GivState()==0) { - if (m_rightop) m_rightop->RestoreState(pile2, bMain); // valeur initiale // interrompu? + if (m_rightop) m_rightop->RestoreState(pile2, bMain); return; } } @@ -1825,55 +1798,58 @@ void CBotExpression::RestoreState(CBotStack* &pj, bool bMain) ////////////////////////////////////////////////////////////////////////////////////// -// compile une instruction de type " ( condition ) " -// la condition doit être de type booléen +// compile a statement such as "(condition)" +// the condition must be Boolean + +// this class has no constructor, because there is never an instance of this class +// the object returned by Compile is usually type CBotExpression -// cette classe n'a pas de constructeur, car il n'y a jamais d'instance de cette classe -// l'objet retourné par Compile est généralement de type CBotExpression CBotInstr* CBotCondition::Compile(CBotToken* &p, CBotCStack* pStack) { pStack->SetStartError(p->GivStart()); - if ( IsOfType(p, ID_OPENPAR )) + if (IsOfType(p, ID_OPENPAR)) { - CBotInstr* inst = CBotBoolExpr::Compile( p, pStack ); - if ( NULL != inst ) + CBotInstr* inst = CBotBoolExpr::Compile(p, pStack); + if (NULL != inst) { - if ( IsOfType(p, ID_CLOSEPAR )) + if (IsOfType(p, ID_CLOSEPAR)) { return inst; } - pStack->SetError(TX_CLOSEPAR, p->GivStart()); // manque la parenthèse + pStack->SetError(TX_CLOSEPAR, p->GivStart()); // missing parenthesis } delete inst; } - pStack->SetError(TX_OPENPAR, p->GivStart()); // manque la parenthèse + pStack->SetError(TX_OPENPAR, p->GivStart()); // missing parenthesis return NULL; } ////////////////////////////////////////////////////////////////////////////////////// -// compile une instruction de type " condition " -// la condition doit être de type booléen - -// cette classe n'a pas de constructeur, car il n'y a jamais d'instance de cette classe -// l'objet retourné par Compile est généralement de type CBotExpression +// compile a statement such as "(condition)" +// the condition must be Boolean +// +// this class has no constructor, because there is never an instance of this +// class +// the object returned by Compile is usually type CBotExpression +// CBotInstr* CBotBoolExpr::Compile(CBotToken* &p, CBotCStack* pStack) { pStack->SetStartError(p->GivStart()); - CBotInstr* inst = CBotTwoOpExpr::Compile( p, pStack ); + CBotInstr* inst = CBotTwoOpExpr::Compile(p, pStack); - if ( NULL != inst ) + if (NULL != inst) { - if ( pStack->GivTypResult().Eq(CBotTypBoolean) ) + if (pStack->GivTypResult().Eq(CBotTypBoolean)) { return inst; } - pStack->SetError(TX_NOTBOOL, p->GivStart()); // n'est pas un booléan + pStack->SetError(TX_NOTBOOL, p->GivStart()); // is not a boolean } delete inst; @@ -1884,18 +1860,19 @@ CBotInstr* CBotBoolExpr::Compile(CBotToken* &p, CBotCStack* pStack) ////////////////////////////////////////////////////////////////////////////////////// -// compile soit : -// une instruction entre parenthèses (...) -// une expression unaire (négatif, not) -// nom de variable -// les variables prè et post incrémentées ou décrémentées -// un nombre donné par DefineNum -// une constante -// un appel de procédure -// l'instruction new - -// cette classe n'a pas de constructeur, car il n'y a jamais d'instance de cette classe -// l'objet retourné par Compile est de la classe correspondant à l'instruction +// compile either: +// instruction in parentheses (...) +// a unary expression (negative, not) +// variable name +// variables pre and post-incremented or decremented +// a given number DefineNum +// a constant +// procedure call +// new statement +// +// this class has no constructor, because there is never an instance of this class +// the object returned by Compile is the class corresponding to the instruction + CBotInstr* CBotParExpr::Compile(CBotToken* &p, CBotCStack* pStack) { @@ -1903,12 +1880,12 @@ CBotInstr* CBotParExpr::Compile(CBotToken* &p, CBotCStack* pStack) pStk->SetStartError(p->GivStart()); - // est-ce une expression entre parenthèse ? + // is it an expression in parentheses? if (IsOfType(p, ID_OPENPAR)) { - CBotInstr* inst = CBotExpression::Compile( p, pStk ); + CBotInstr* inst = CBotExpression::Compile(p, pStk); - if ( NULL != inst ) + if (NULL != inst) { if (IsOfType(p, ID_CLOSEPAR)) { @@ -1920,41 +1897,41 @@ CBotInstr* CBotParExpr::Compile(CBotToken* &p, CBotCStack* pStack) return pStack->Return(NULL, pStk); } - // est-ce une opération unaire ? + // is this a unary operation? CBotInstr* inst = CBotExprUnaire::Compile(p, pStk); if (inst != NULL || !pStk->IsOk()) return pStack->Return(inst, pStk); - // est-ce un nom de variable ? + // is it a variable name? if (p->GivType() == TokenTypVar) { - // c'est peut-être un appel de méthode sans le "this." devant + // this may be a method call without the "this." before inst = CBotExprVar::CompileMethode(p, pStk); - if ( inst != NULL ) return pStack->Return(inst, pStk); + if (inst != NULL) return pStack->Return(inst, pStk); - // est-ce un appel de procédure ? + // is it a procedure call? inst = CBotInstrCall::Compile(p, pStk); - if ( inst != NULL || !pStk->IsOk() ) + if (inst != NULL || !pStk->IsOk()) return pStack->Return(inst, pStk); CBotToken* pvar = p; - // non, c'est une variable "ordinaire" + // no, it an "ordinaty" variable inst = CBotExprVar::Compile(p, pStk); CBotToken* pp = p; - // post incrémenté ou décrémenté ? + // post incremented or decremented? if (IsOfType(p, ID_INC, ID_DEC)) { - if ( pStk->GivType() >= CBotTypBoolean ) + if (pStk->GivType() >= CBotTypBoolean) { pStk->SetError(TX_BADTYPE, pp); delete inst; return pStack->Return(NULL, pStk); } - // recompile la variable pour read-only + // recompile the variable for read-only delete inst; p = pvar; inst = CBotExprVar::Compile(p, pStk, PR_READ); @@ -1962,13 +1939,13 @@ CBotInstr* CBotParExpr::Compile(CBotToken* &p, CBotCStack* pStack) CBotPostIncExpr* i = new CBotPostIncExpr(); i->SetToken(pp); - i->m_Instr = inst; // instruction associée + i->m_Instr = inst; // associated statement return pStack->Return(i, pStk); } return pStack->Return(inst, pStk); } - // est-ce une variable préincrémentée ou prédécrémentée ? + // pre increpemted or pre decremented? CBotToken* pp = p; if (IsOfType(p, ID_INC, ID_DEC)) { @@ -1979,7 +1956,7 @@ CBotInstr* CBotParExpr::Compile(CBotToken* &p, CBotCStack* pStack) { if (NULL != (i->m_Instr = CBotExprVar::Compile(p, pStk, PR_READ))) { - if ( pStk->GivType() >= CBotTypBoolean ) + if (pStk->GivType() >= CBotTypBoolean) { pStk->SetError(TX_BADTYPE, pp); delete inst; @@ -1992,51 +1969,51 @@ CBotInstr* CBotParExpr::Compile(CBotToken* &p, CBotCStack* pStack) } } - // est-ce un nombre ou un DefineNum ? + // is it a number or DefineNum? if (p->GivType() == TokenTypNum || p->GivType() == TokenTypDef ) { - CBotInstr* inst = CBotExprNum::Compile( p, pStk ); + CBotInstr* inst = CBotExprNum::Compile(p, pStk); return pStack->Return(inst, pStk); } - // est-ce une chaine ? + // is this a chaine? if (p->GivType() == TokenTypString) { CBotInstr* inst = CBotExprAlpha::Compile(p, pStk); return pStack->Return(inst, pStk); } - // est un élément "true" ou "false" + // is a "true" or "false" if (p->GivType() == ID_TRUE || p->GivType() == ID_FALSE ) { - CBotInstr* inst = CBotExprBool::Compile( p, pStk ); + CBotInstr* inst = CBotExprBool::Compile(p, pStk); return pStack->Return(inst, pStk); } - // est un objet à créer avec new + // is an object to be created with new if (p->GivType() == ID_NEW) { - CBotInstr* inst = CBotNew::Compile( p, pStk ); + CBotInstr* inst = CBotNew::Compile(p, pStk); return pStack->Return(inst, pStk); } - // est un pointeur nul - if (IsOfType( p, ID_NULL )) + // is a null pointer + if (IsOfType(p, ID_NULL)) { CBotInstr* inst = new CBotExprNull (); - inst->SetToken( pp ); + inst->SetToken(pp); CBotVar* var = CBotVar::Create("", CBotTypNullPointer); pStk->SetVar(var); return pStack->Return(inst, pStk); } - // est un nombre nan - if (IsOfType( p, ID_NAN )) + // is a number nan + if (IsOfType(p, ID_NAN)) { CBotInstr* inst = new CBotExprNan (); - inst->SetToken( pp ); + inst->SetToken(pp); CBotVar* var = CBotVar::Create("", CBotTypInt); var->SetInit(IS_NAN); pStk->SetVar(var); @@ -2050,10 +2027,10 @@ CBotInstr* CBotParExpr::Compile(CBotToken* &p, CBotCStack* pStack) ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// -// gestion du post et pré- incrément/décrément +// Management of pre-and post increment / decrement +// There is no routine Compiles, the object is created directly +// Compiles in CBotParExpr :: -// il n'y a pas de routine Compile, l'objet est créé directement -// dans CBotParExpr::Compile CBotPostIncExpr::CBotPostIncExpr() { @@ -2084,88 +2061,89 @@ bool CBotPostIncExpr::Execute(CBotStack* &pj) CBotVar* var1 = NULL; - if ( !((CBotExprVar*)m_Instr)->ExecuteVar(var1, pile2, NULL, true) ) return false; // récupère la variable selon champs et index + // retrieves the variable fields and indexes according + if (!((CBotExprVar*)m_Instr)->ExecuteVar(var1, pile2, NULL, true)) return false; pile1->SetState(1); pile1->SetCopyVar(var1); // place le résultat (avant incrémentation); CBotStack* pile3 = pile2->AddStack(this); - if ( pile3->IfStep() ) return false; + if (pile3->IfStep()) return false; - if ( var1->GivInit() == IS_NAN ) + if (var1->GivInit() == IS_NAN) { - pile1->SetError( TX_OPNAN, &m_token ); + pile1->SetError(TX_OPNAN, &m_token); } - if ( var1->GivInit() != IS_DEF ) + if (var1->GivInit() != IS_DEF) { - pile1->SetError( TX_NOTINIT, &m_token ); + pile1->SetError(TX_NOTINIT, &m_token); } if (GivTokenType() == ID_INC) var1->Inc(); else var1->Dec(); - return pj->Return(pile1); // opération faite, résultat sur pile2 + return pj->Return(pile1); // operation done, result on pile2 } void CBotPostIncExpr::RestoreState(CBotStack* &pj, bool bMain) { - if ( !bMain ) return; + if (!bMain) return; CBotStack* pile1 = pj->RestoreStack(this); - if ( pile1 == NULL ) return; + if (pile1 == NULL) return; ((CBotExprVar*)m_Instr)->RestoreStateVar(pile1, bMain); - if ( pile1 != NULL ) pile1->RestoreStack(this); + if (pile1 != NULL) pile1->RestoreStack(this); } bool CBotPreIncExpr::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return false; + if (pile->IfStep()) return false; CBotVar* var1; - if ( pile->GivState() == 0 ) + if (pile->GivState() == 0) { CBotStack* pile2 = pile; - if ( !((CBotExprVar*)m_Instr)->ExecuteVar(var1, pile2, NULL, true) ) return false; // récupère la variable selon champs et index - // pile2 est modifié en retour + // retrieves the variable fields and indexes according + // pile2 is modified on return + if (!((CBotExprVar*)m_Instr)->ExecuteVar(var1, pile2, NULL, true)) return false; - if ( var1->GivInit() == IS_NAN ) + if (var1->GivInit() == IS_NAN) { - pile->SetError( TX_OPNAN, &m_token ); - return pj->Return(pile); // opération faite + pile->SetError(TX_OPNAN, &m_token); + return pj->Return(pile); // operation performed } - if ( var1->GivInit() != IS_DEF ) + if (var1->GivInit() != IS_DEF) { - pile->SetError( TX_NOTINIT, &m_token ); - return pj->Return(pile); // opération faite + pile->SetError(TX_NOTINIT, &m_token); + return pj->Return(pile); // operation performed } if (GivTokenType() == ID_INC) var1->Inc(); - else var1->Dec(); // ((CBotVarInt*)var1)->m_val + else var1->Dec(); // ((CBotVarInt*)var1)->m_val pile->IncState(); } - if ( !m_Instr->Execute(pile) ) return false; - return pj->Return(pile); // opération faite + if (!m_Instr->Execute(pile)) return false; + return pj->Return(pile); // operation performed } void CBotPreIncExpr::RestoreState(CBotStack* &pj, bool bMain) { - if ( !bMain ) return; + if (!bMain) return; CBotStack* pile = pj->RestoreStack(this); - if ( pile == NULL ) return; + if (pile == NULL) return; - if ( pile->GivState() == 0 ) + if (pile->GivState() == 0) { return; } @@ -2175,7 +2153,7 @@ void CBotPreIncExpr::RestoreState(CBotStack* &pj, bool bMain) ////////////////////////////////////////////////////////////////////////////////////// -// compile une expression unaire +// compile an unary expression // + // - // not @@ -2197,24 +2175,24 @@ CBotInstr* CBotExprUnaire::Compile(CBotToken* &p, CBotCStack* pStack) { int op = p->GivType(); CBotToken* pp = p; - if ( !IsOfTypeList( p, ID_ADD, ID_SUB, ID_LOG_NOT, ID_TXT_NOT, ID_NOT, 0 ) ) return NULL; + if (!IsOfTypeList( p, ID_ADD, ID_SUB, ID_LOG_NOT, ID_TXT_NOT, ID_NOT, 0 )) return NULL; CBotCStack* pStk = pStack->TokenStack(pp); CBotExprUnaire* inst = new CBotExprUnaire(); inst->SetToken(pp); - if ( NULL != (inst->m_Expr = CBotParExpr::Compile( p, pStk )) ) + if (NULL != (inst->m_Expr = CBotParExpr::Compile( p, pStk ))) { - if ( op == ID_ADD && pStk->GivType() < CBotTypBoolean ) // seulement avec des nombre + if (op == ID_ADD && pStk->GivType() < CBotTypBoolean) // only with the number return pStack->Return(inst, pStk); - if ( op == ID_SUB && pStk->GivType() < CBotTypBoolean ) // seulement avec des nombre + if (op == ID_SUB && pStk->GivType() < CBotTypBoolean) // only with the numer return pStack->Return(inst, pStk); - if ( op == ID_NOT && pStk->GivType() < CBotTypFloat ) // seulement avec des entiers + if (op == ID_NOT && pStk->GivType() < CBotTypFloat) // only with an integer return pStack->Return(inst, pStk); - if ( op == ID_LOG_NOT && pStk->GivTypResult().Eq(CBotTypBoolean) )// seulement avec des booléens + if (op == ID_LOG_NOT && pStk->GivTypResult().Eq(CBotTypBoolean))// only with boolean return pStack->Return(inst, pStk); - if ( op == ID_TXT_NOT && pStk->GivTypResult().Eq(CBotTypBoolean) )// seulement avec des booléens + if (op == ID_TXT_NOT && pStk->GivTypResult().Eq(CBotTypBoolean))// only with boolean return pStack->Return(inst, pStk); pStk->SetError(TX_BADTYPE, &inst->m_token); @@ -2223,30 +2201,29 @@ CBotInstr* CBotExprUnaire::Compile(CBotToken* &p, CBotCStack* pStack) return pStack->Return(NULL, pStk); } -// exécute l'expresson unaire +// executes unary expression bool CBotExprUnaire::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return true; - if ( pile->GivState() == 0 ) + if (pile->GivState() == 0) { - if (!m_Expr->Execute( pile )) return false; // interrompu ? + if (!m_Expr->Execute(pile)) return false; // interrupted ? pile->IncState(); } CBotStack* pile2 = pile->AddStack(); - if ( pile2->IfStep() ) return false; + if (pile2->IfStep()) return false; - CBotVar* var = pile->GivVar(); // récupère le résultat sur la pile + CBotVar* var = pile->GivVar(); // get the result on the stack switch (GivTokenType()) { case ID_ADD: - break; // ne fait donc rien + break; case ID_SUB: - var->Neg(); // change le signe + var->Neg(); // change the sign break; case ID_NOT: case ID_LOG_NOT: @@ -2254,19 +2231,19 @@ bool CBotExprUnaire::Execute(CBotStack* &pj) var->Not(); break; } - return pj->Return(pile); // transmet en dessous + return pj->Return(pile); // forwards below } void CBotExprUnaire::RestoreState(CBotStack* &pj, bool bMain) { - if ( !bMain ) return; + if (!bMain) return; CBotStack* pile = pj->RestoreStack(this); if ( pile == NULL) return; - if ( pile->GivState() == 0 ) + if (pile->GivState() == 0) { - m_Expr->RestoreState( pile, bMain ); // interrompu ici ! + m_Expr->RestoreState(pile, bMain); // interrupted here! return; } } @@ -2274,7 +2251,7 @@ void CBotExprUnaire::RestoreState(CBotStack* &pj, bool bMain) ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// -// gestion des index pour les tableaux +// index management for arrays // array [ expression ] @@ -2289,95 +2266,89 @@ CBotIndexExpr::~CBotIndexExpr() delete m_expr; } -// trouve un champ à partir de l'instance à la compilation +// finds a field from the instance at compile time bool CBotIndexExpr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) { - if ( pVar->GivType(1) != CBotTypArrayPointer ) + if (pVar->GivType(1) != CBotTypArrayPointer) ASM_TRAP(); - pVar = ((CBotVarArray*)pVar)->GivItem(0, false); // à la compilation rend l'élément [0] - if ( pVar == NULL ) + pVar = ((CBotVarArray*)pVar)->GivItem(0, false); // at compile time makes the element [0] + if (pVar == NULL) { pile->SetError(TX_OUTARRAY, m_token.GivEnd()); return false; } - if ( m_next3 != NULL ) return m_next3->ExecuteVar(pVar, pile); + if (m_next3 != NULL) return m_next3->ExecuteVar(pVar, pile); return true; } -// idem à l'exécution -// attention, modifie le pointeur à la pile volontairement -// place les index calculés sur la pile supplémentaire +// attention, changes the pointer to the stack intentionally +// place the index calculated on the additional stack + bool CBotIndexExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep, bool bExtend) { CBotStack* pj = pile; -// DEBUG( "CBotIndexExpr::ExecuteVar", -1 , pj); - if ( pVar->GivType(1) != CBotTypArrayPointer ) + if (pVar->GivType(1) != CBotTypArrayPointer) ASM_TRAP(); pile = pile->AddStack(); -// if ( pile == EOX ) return true; - if ( pile->GivState() == 0 ) + if (pile->GivState() == 0) { - if ( !m_expr->Execute(pile) ) return false; + if (!m_expr->Execute(pile)) return false; pile->IncState(); } - // traite les tableaux + // handles array - CBotVar* p = pile->GivVar(); // résultat sur la pile + CBotVar* p = pile->GivVar(); // result on the stack - if ( p == NULL || p->GivType() > CBotTypDouble ) + if (p == NULL || p->GivType() > CBotTypDouble) { pile->SetError(TX_BADINDEX, prevToken); return pj->Return(pile); } - int n = p->GivValInt(); // position dans le tableau -// DEBUG( "CBotIndexExpr::ExecuteVar", n , pj); + int n = p->GivValInt(); // position in the table pVar = ((CBotVarArray*)pVar)->GivItem(n, bExtend); - if ( pVar == NULL ) + if (pVar == NULL) { pile->SetError(TX_OUTARRAY, prevToken); return pj->Return(pile); } -// DEBUG( "CBotIndexExpr::ExecuteVar", -2 , pj); - //if ( bUpdate ) - pVar->Maj(pile->GivPUser(), true); + pVar->Maj(pile->GivPUser(), true); -// DEBUG( "CBotIndexExpr::ExecuteVar", -3 , pj); if ( m_next3 != NULL && !m_next3->ExecuteVar(pVar, pile, prevToken, bStep, bExtend) ) return false; -// DEBUG( "CBotIndexExpr::ExecuteVar", -4 , pj); - return true; // ne libère pas la pile - // pour éviter de recalculer les index deux fois le cas échéant + // does not release the stack + // to avoid recalculation of the index twice where appropriate + return true; } void CBotIndexExpr::RestoreStateVar(CBotStack* &pile, bool bMain) { pile = pile->RestoreStack(); - if ( pile == NULL ) return; + if (pile == NULL) return; - if ( bMain && pile->GivState() == 0 ) + if (bMain && pile->GivState() == 0) { m_expr->RestoreState(pile, true); return; } - if ( m_next3 ) + if (m_next3) m_next3->RestoreStateVar(pile, bMain); } ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// -// gestion des champs dans une instance (opérateur point) +// field management in an instance (dot operator) // toto.x @@ -2397,16 +2368,15 @@ void CBotFieldExpr::SetUniqNum(int num) } -// trouve un champ à partir de l'instance à la compilation +// find a field from the instance at compile bool CBotFieldExpr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) { - if ( pVar->GivType(1) != CBotTypPointer ) + if (pVar->GivType(1) != CBotTypPointer) ASM_TRAP(); -// pVar = pVar->GivItem(m_token.GivString()); pVar = pVar->GivItemRef(m_nIdent); - if ( pVar == NULL ) + if (pVar == NULL) { pile->SetError(TX_NOITEM, &m_token); return false; @@ -2418,74 +2388,69 @@ bool CBotFieldExpr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) return true; } -// idem à l'exécution - bool CBotFieldExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep, bool bExtend) { CBotStack* pj = pile; - pile = pile->AddStack(this); // modifie pile en sortie - if ( pile == EOX ) return true; + pile = pile->AddStack(this); // changes in output stack + if (pile == EOX) return true; -// DEBUG( "CBotFieldExpre::ExecuteVar "+m_token.GivString(), 0, pj ); - if ( pVar->GivType(1) != CBotTypPointer ) + if (pVar->GivType(1) != CBotTypPointer) ASM_TRAP(); CBotVarClass* pItem = pVar->GivPointer(); - if ( pItem == NULL ) + if (pItem == NULL) { pile->SetError(TX_NULLPT, prevToken); - return pj->Return( pile ); + return pj->Return(pile); } - if ( pItem->GivUserPtr() == OBJECTDELETED ) + if (pItem->GivUserPtr() == OBJECTDELETED) { pile->SetError(TX_DELETEDPT, prevToken); - return pj->Return( pile ); + return pj->Return(pile); } - if ( bStep && pile->IfStep() ) return false; + if (bStep && pile->IfStep()) return false; -// pVar = pVar->GivItem(m_token.GivString()); pVar = pVar->GivItemRef(m_nIdent); - if ( pVar == NULL ) + if (pVar == NULL) { pile->SetError(TX_NOITEM, &m_token); - return pj->Return( pile ); + return pj->Return(pile); } - if ( pVar->IsStatic() ) + if (pVar->IsStatic()) { -// DEBUG( "IsStatic", 0, pj) ; - // pour une variable statique, la prend dans la classe elle-même + // for a static variable, takes it in the class itself CBotClass* pClass = pItem->GivClass(); pVar = pClass->GivItem(m_token.GivString()); -// DEBUG( "done "+pVar->GivName(), 0, pj) ; } - // demande la mise à jour de l'élément, s'il y a lieu + // request the update of the element, if applicable pVar->Maj(pile->GivPUser(), true); if ( m_next3 != NULL && !m_next3->ExecuteVar(pVar, pile, &m_token, bStep, bExtend) ) return false; - return true; // ne libère pas la pile - // pour conserver l'état SetState() correspondant à l'étape + // does not release the stack + // to maintain the state SetState () corresponding to step + + return true; } void CBotFieldExpr::RestoreStateVar(CBotStack* &pj, bool bMain) { - pj = pj->RestoreStack(this); // modifie pj en sortie - if ( pj == NULL ) return; + pj = pj->RestoreStack(this); + if (pj == NULL) return; - if ( m_next3 != NULL ) + if (m_next3 != NULL) m_next3->RestoreStateVar(pj, bMain); } ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// -// compile un opérande gauche pour une assignation - +// compile a left operand for an assignment CBotLeftExpr::CBotLeftExpr() { name = "CBotLeftExpr"; @@ -2515,13 +2480,13 @@ CBotLeftExpr* CBotLeftExpr::Compile(CBotToken* &p, CBotCStack* pStack) // is it a variable name? if (p->GivType() == TokenTypVar) { - CBotLeftExpr* inst = new CBotLeftExpr(); // creates the object + CBotLeftExpr* inst = new CBotLeftExpr(); // creates the object inst->SetToken(p); CBotVar* var; - if ( NULL != (var = pStk->FindVar(p)) ) // seek if known variable + if (NULL != (var = pStk->FindVar(p))) // seek if known variable { inst->m_nIdent = var->GivUniqNum(); if (inst->m_nIdent > 0 && inst->m_nIdent < 9000) @@ -2529,81 +2494,81 @@ CBotLeftExpr* CBotLeftExpr::Compile(CBotToken* &p, CBotCStack* pStack) if ( var->IsPrivate(PR_READ) && !pStk->GivBotCall()->m_bCompileClass) { - pStk->SetError( TX_PRIVATE, p ); + pStk->SetError(TX_PRIVATE, p); goto err; } - // il s'agit d'un élement de la classe courante - // ajoute l'équivalent d'un this. devant + // this is an element of the current class + // adds the equivalent of this. before CBotToken pthis("this"); inst->SetToken(&pthis); - inst->m_nIdent = -2; // ident pour this + inst->m_nIdent = -2; // indent for this - CBotFieldExpr* i = new CBotFieldExpr(); // nouvel élément - i->SetToken( p ); // garde le nom du token - inst->AddNext3(i); // ajoute à la suite + CBotFieldExpr* i = new CBotFieldExpr(); // new element + i->SetToken(p); // keeps the name of the token + inst->AddNext3(i); // add after var = pStk->FindVar(pthis); var = var->GivItem(p->GivString()); i->SetUniqNum(var->GivUniqNum()); } - p = p->GivNext(); // token suivant + p = p->GivNext(); // next token while (true) { - if ( var->GivType() == CBotTypArrayPointer ) // s'il sagit d'un tableau + if (var->GivType() == CBotTypArrayPointer) { - if ( IsOfType( p, ID_OPBRK ) ) // regarde s'il y a un index + if (IsOfType( p, ID_OPBRK )) { CBotIndexExpr* i = new CBotIndexExpr(); - i->m_expr = CBotExpression::Compile(p, pStk); // compile la formule - inst->AddNext3(i); // ajoute à la chaine + i->m_expr = CBotExpression::Compile(p, pStk); + inst->AddNext3(i); // add to the chain - var = ((CBotVarArray*)var)->GivItem(0,true); // donne le composant [0] + var = ((CBotVarArray*)var)->GivItem(0,true); // gets the component [0] - if ( i->m_expr == NULL ) + if (i->m_expr == NULL) { - pStk->SetError( TX_BADINDEX, p->GivStart() ); + pStk->SetError(TX_BADINDEX, p->GivStart()); goto err; } - if ( !pStk->IsOk() || !IsOfType( p, ID_CLBRK ) ) + if (!pStk->IsOk() || !IsOfType( p, ID_CLBRK )) { - pStk->SetError( TX_CLBRK, p->GivStart() ); + pStk->SetError(TX_CLBRK, p->GivStart()); goto err; } continue; } } - if ( var->GivType(1) == CBotTypPointer ) // pour les classes + if (var->GivType(1) == CBotTypPointer) // for classes { - if ( IsOfType(p, ID_DOT) ) + if (IsOfType(p, ID_DOT)) { CBotToken* pp = p; - CBotFieldExpr* i = new CBotFieldExpr(); // nouvel élément - i->SetToken( pp ); // garde le nom du token - inst->AddNext3(i); // ajoute à la suite + CBotFieldExpr* i = new CBotFieldExpr(); // new element + i->SetToken(pp); // keeps the name of the token + inst->AddNext3(i); // adds after - if ( p->GivType() == TokenTypVar ) // doit être un nom + if (p->GivType() == TokenTypVar) // must be a name { - var = var->GivItem(p->GivString()); // récupère l'item correpondant - if ( var != NULL ) + var = var->GivItem(p->GivString()); // get item correspondent + if (var != NULL) { if ( var->IsPrivate(PR_READ) && !pStk->GivBotCall()->m_bCompileClass) { - pStk->SetError( TX_PRIVATE, pp ); + pStk->SetError(TX_PRIVATE, pp); goto err; } i->SetUniqNum(var->GivUniqNum()); - p = p->GivNext(); // saute le nom + p = p->GivNext(); // skips the name continue; } - pStk->SetError( TX_NOITEM, p ); + pStk->SetError(TX_NOITEM, p); } - pStk->SetError( TX_DOT, p->GivStart() ); + pStk->SetError(TX_DOT, p->GivStart()); goto err; } } @@ -2611,7 +2576,7 @@ CBotLeftExpr* CBotLeftExpr::Compile(CBotToken* &p, CBotCStack* pStack) } - if ( pStk->IsOk() ) return (CBotLeftExpr*) pStack->Return(inst, pStk); + if (pStk->IsOk()) return (CBotLeftExpr*) pStack->Return(inst, pStk); } pStk->SetError(TX_UNDEFVAR, p); err: @@ -2622,31 +2587,26 @@ err: return (CBotLeftExpr*) pStack->Return(NULL, pStk); } -// exécute, trouve une variable et lui assigne le résultat de la pile - +// runs, is a variable and assigns the result to the stack bool CBotLeftExpr::Execute(CBotStack* &pj, CBotStack* array) { CBotStack* pile = pj->AddStack(); -// if ( pile == EOX ) return true; - -// if ( pile->IfStep() ) return false; CBotVar* var1 = NULL; CBotVar* var2 = NULL; + // fetch a variable (not copy) + if (!ExecuteVar(var1, array, NULL, false)) return false; -// var1 = pile->FindVar(m_token, false, true); - if (!ExecuteVar( var1, array, NULL, false )) return false; - // retrouve la variable (et pas la copie) if (pile->IfStep()) return false; - if ( var1 ) + if (var1) { - var2 = pj->GivVar(); // resultat sur la pile d'entrée - if ( var2 ) + var2 = pj->GivVar(); // result on the input stack + if (var2) { CBotTypResult t1 = var1->GivTypResult(); CBotTypResult t2 = var2->GivTypResult(); - if ( t2.Eq(CBotTypPointer) ) + if (t2.Eq(CBotTypPointer)) { CBotClass* c1 = t1.GivClass(); CBotClass* c2 = t2.GivClass(); @@ -2654,24 +2614,24 @@ bool CBotLeftExpr::Execute(CBotStack* &pj, CBotStack* array) { CBotToken* pt = &m_token; pile->SetError(TX_BADTYPE, pt); - return pj->Return(pile); // opération faite + return pj->Return(pile); // operation performed } } - var1->SetVal(var2); // fait l'assignation + var1->SetVal(var2); // do assignment } - pile->SetCopyVar( var1 ); // remplace sur la pile par une copie de la variable elle-même - // (pour avoir le nom) + pile->SetCopyVar(var1); // replace the stack with the copy of the variable + // (for name) } - return pj->Return(pile); // opération faite + return pj->Return(pile); // operation performed } -// retrouve une variable pendant la compilation +// fetch a variable during compilation bool CBotLeftExpr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) { pVar = pile->FindVar(m_token); - if ( pVar == NULL ) return false; + if (pVar == NULL) return false; if ( m_next3 != NULL && !m_next3->ExecuteVar(pVar, pile) ) return false; @@ -2679,14 +2639,14 @@ bool CBotLeftExpr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) return true; } -// retrouve une variable à l'exécution +// fetch the variable at runtume bool CBotLeftExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep) { - pile = pile->AddStack( this ); // déplace la pile + pile = pile->AddStack(this); pVar = pile->FindVar(m_nIdent); - if ( pVar == NULL ) + if (pVar == NULL) { #ifdef _DEBUG ASM_TRAP(); @@ -2695,7 +2655,7 @@ bool CBotLeftExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevT return false; } - if ( bStep && m_next3 == NULL && pile->IfStep() ) return false; + if (bStep && m_next3 == NULL && pile->IfStep()) return false; if ( m_next3 != NULL && !m_next3->ExecuteVar(pVar, pile, &m_token, bStep, true) ) return false; @@ -2705,19 +2665,19 @@ bool CBotLeftExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevT void CBotLeftExpr::RestoreStateVar(CBotStack* &pile, bool bMain) { - pile = pile->RestoreStack( this ); // déplace la pile - if ( pile == NULL ) return; + pile = pile->RestoreStack(this); + if (pile == NULL) return; - if ( m_next3 != NULL ) + if (m_next3 != NULL) m_next3->RestoreStateVar(pile, bMain); } ////////////////////////////////////////////////////////////////////////////////////////// -// transforme une chaîne en nombre entier -// peut être de la forme 0xabc123 +// converts a string into integer +// may be of the form 0xabc123 -long GivNumInt( const char* p ) +long GivNumInt(const char* p) { long num = 0; while (*p >= '0' && *p <= '9') @@ -2725,21 +2685,21 @@ long GivNumInt( const char* p ) num = num * 10 + *p - '0'; p++; } - if ( *p == 'x' || *p == 'X' ) + if (*p == 'x' || *p == 'X') { while (*++p != 0) { - if ( *p >= '0' && *p <= '9' ) + if (*p >= '0' && *p <= '9') { num = num * 16 + *p - '0'; continue; } - if ( *p >= 'A' && *p <= 'F' ) + if (*p >= 'A' && *p <= 'F') { num = num * 16 + *p - 'A' + 10; continue; } - if ( *p >= 'a' && *p <= 'f' ) + if (*p >= 'a' && *p <= 'f') { num = num * 16 + *p - 'a' + 10; continue; @@ -2750,9 +2710,8 @@ long GivNumInt( const char* p ) return num; } -// transforme une chaîne en un nombre réel - -extern float GivNumFloat( const char* p ) +// converts a string into a float number +extern float GivNumFloat(const char* p) { double num = 0; double div = 10; @@ -2769,7 +2728,7 @@ extern float GivNumFloat( const char* p ) p++; } - if ( *p == '.' ) + if (*p == '.') { p++; while (*p >= '0' && *p <= '9') @@ -2781,33 +2740,33 @@ extern float GivNumFloat( const char* p ) } int exp = 0; - if ( *p == 'e' || *p == 'E' ) + if (*p == 'e' || *p == 'E') { char neg = 0; p++; - if ( *p == '-' || *p == '+' ) neg = *p++; + if (*p == '-' || *p == '+') neg = *p++; while (*p >= '0' && *p <= '9') { exp = exp * 10 + (*p - '0'); p++; } - if ( neg == '-' ) exp = -exp; + if (neg == '-') exp = -exp; } - while ( exp > 0 ) + while (exp > 0) { num *= 10.0; exp--; } - while ( exp < 0 ) + while (exp < 0) { num /= 10.0; exp++; } - if ( bNeg ) num = -num; + if (bNeg) num = -num; return (float)num; } @@ -2815,8 +2774,7 @@ extern float GivNumFloat( const char* p ) ////////////////////////////////////////////////////////////////////////////////////// -// compile un token représentant un nombre - +// compiles a token representing a number CBotExprNum::CBotExprNum() { name = "CBotExprNum"; @@ -2836,13 +2794,13 @@ CBotInstr* CBotExprNum::Compile(CBotToken* &p, CBotCStack* pStack) CBotString s = p->GivString(); inst->m_numtype = CBotTypInt; - if ( p->GivType() == TokenTypDef ) + if (p->GivType() == TokenTypDef) { inst->m_valint = p->GivIdKey(); } else { - if ( s.Find('.') >= 0 || ( s.Find('x') < 0 && ( s.Find('e') >= 0 || s.Find('E') >= 0 ) ) ) + if (s.Find('.') >= 0 || ( s.Find('x') < 0 && ( s.Find('e') >= 0 || s.Find('E') >= 0 ) )) { inst->m_numtype = CBotTypFloat; inst->m_valfloat = GivNumFloat(s); @@ -2864,19 +2822,18 @@ CBotInstr* CBotExprNum::Compile(CBotToken* &p, CBotCStack* pStack) return pStack->Return(NULL, pStk); } -// exécute, retourne le nombre correspondant +// execute, returns the corresponding number bool CBotExprNum::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return false; + if (pile->IfStep()) return false; CBotVar* var = CBotVar::Create((CBotToken*)NULL, m_numtype); CBotString nombre ; - if ( m_token.GivType() == TokenTypDef ) + if (m_token.GivType() == TokenTypDef) { nombre = m_token.GivString(); } @@ -2885,27 +2842,27 @@ bool CBotExprNum::Execute(CBotStack* &pj) { case CBotTypShort: case CBotTypInt: - var->SetValInt( m_valint, nombre ); // valeur du nombre + var->SetValInt(m_valint, nombre); break; case CBotTypFloat: - var->SetValFloat( m_valfloat ); // valeur du nombre + var->SetValFloat(m_valfloat); break; } - pile->SetVar( var ); // mis sur la pile + pile->SetVar(var); // place on the stack - return pj->Return(pile); // c'est ok + return pj->Return(pile); // it's ok } void CBotExprNum::RestoreState(CBotStack* &pj, bool bMain) { - if ( bMain ) pj->RestoreStack(this); + if (bMain) pj->RestoreStack(this); } ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// -// compile un token représentant une chaine de caractères +// compile a token representing a string CBotExprAlpha::CBotExprAlpha() { @@ -2931,37 +2888,36 @@ CBotInstr* CBotExprAlpha::Compile(CBotToken* &p, CBotCStack* pStack) return pStack->Return(inst, pStk); } -// exécute, retourne la chaîne correspondante +// execute, returns the corresponding string bool CBotExprAlpha::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return false; + if (pile->IfStep()) return false; CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypString); CBotString chaine = m_token.GivString(); - chaine = chaine.Mid(1, chaine.GivLength()-2); // enlève les guillemets + chaine = chaine.Mid(1, chaine.GivLength()-2); // removes the quotes - var->SetValString( chaine ); // valeur du nombre + var->SetValString(chaine); // value of the number - pile->SetVar( var ); // mis sur la pile + pile->SetVar(var); // put on the stack return pj->Return(pile); } void CBotExprAlpha::RestoreState(CBotStack* &pj, bool bMain) { - if ( bMain ) pj->RestoreStack(this); + if (bMain) pj->RestoreStack(this); } ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// -// compile un token représentant true ou false +// compile a token representing true or false CBotExprBool::CBotExprBool() { @@ -2981,7 +2937,7 @@ CBotInstr* CBotExprBool::Compile(CBotToken* &p, CBotCStack* pStack) p->GivType() == ID_FALSE ) { inst = new CBotExprBool(); - inst->SetToken(p); // mémorise l'opération false ou true + inst->SetToken(p); // stores the operation false or true p = p->GivNext(); CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypBoolean); @@ -2991,32 +2947,31 @@ CBotInstr* CBotExprBool::Compile(CBotToken* &p, CBotCStack* pStack) return pStack->Return(inst, pStk); } -// exécute, retourne true ou false +// executes, returns true or false bool CBotExprBool::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return false; + if (pile->IfStep()) return false; CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypBoolean); if (GivTokenType() == ID_TRUE) var->SetValInt(1); else var->SetValInt(0); - pile->SetVar( var ); // mis sur la pile - return pj->Return(pile); // transmet en dessous + pile->SetVar(var); // put on the stack + return pj->Return(pile); // forwards below } void CBotExprBool::RestoreState(CBotStack* &pj, bool bMain) { - if ( bMain ) pj->RestoreStack(this); + if (bMain) pj->RestoreStack(this); } ////////////////////////////////////////////////////////////////////////////////////////// -// gestion de l'opérande "null" +// management of the operand "null" CBotExprNull::CBotExprNull() { @@ -3027,29 +2982,28 @@ CBotExprNull::~CBotExprNull() { } -// exécute, retourne un pointeur vide +// executes, returns an empty pointer bool CBotExprNull::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return false; + if (pile->IfStep()) return false; CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypNullPointer); - var->SetInit(true); // pointeur null valide - pile->SetVar( var ); // mis sur la pile - return pj->Return(pile); // transmet en dessous + var->SetInit(true); // null pointer valid + pile->SetVar(var); // place on the stack + return pj->Return(pile); // forwards below } void CBotExprNull::RestoreState(CBotStack* &pj, bool bMain) { - if ( bMain ) pj->RestoreStack(this); + if (bMain) pj->RestoreStack(this); } ////////////////////////////////////////////////////////////////////////////////////////// -// gestion de l'opérande "nan" +// management of the operand "nan" CBotExprNan::CBotExprNan() { @@ -3060,30 +3014,29 @@ CBotExprNan::~CBotExprNan() { } -// exécute, retourne un pointeur vide +// executes, returns null pointer bool CBotExprNan::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return false; + if (pile->IfStep()) return false; CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypInt); - var->SetInit(IS_NAN); // nombre nan - pile->SetVar( var ); // mis sur la pile - return pj->Return(pile); // transmet en dessous + var->SetInit(IS_NAN); // nan + pile->SetVar(var); // put on the stack + return pj->Return(pile); // forward below } void CBotExprNan::RestoreState(CBotStack* &pj, bool bMain) { - if ( bMain ) pj->RestoreStack(this); + if (bMain) pj->RestoreStack(this); } ////////////////////////////////////////////////////////////////////////////////////// -// compile un nom de variable -// vérifie qu'elle est connue sur la pile -// et qu'elle a été initialisée +// compile a variable name +// check that it is known on the stack +// and it has been initialized CBotExprVar::CBotExprVar() { @@ -3105,23 +3058,23 @@ CBotInstr* CBotExprVar::Compile(CBotToken* &p, CBotCStack* pStack, int privat) // is it a variable? if (p->GivType() == TokenTypVar) { - CBotInstr* inst = new CBotExprVar(); // create the object + CBotInstr* inst = new CBotExprVar(); // create the object inst->SetToken(p); CBotVar* var; - if ( NULL != (var = pStk->FindVar(p)) ) // seek if known variable + if (NULL != (var = pStk->FindVar(p))) // seek if known variable { int ident = var->GivUniqNum(); - ((CBotExprVar*)inst)->m_nIdent = ident; // identifies variable by its number + ((CBotExprVar*)inst)->m_nIdent = ident; // identifies variable by its number if (ident > 0 && ident < 9000) { if ( var->IsPrivate(privat) && !pStk->GivBotCall()->m_bCompileClass) { - pStk->SetError( TX_PRIVATE, p ); + pStk->SetError(TX_PRIVATE, p); goto err; } @@ -3131,85 +3084,84 @@ CBotInstr* CBotExprVar::Compile(CBotToken* &p, CBotCStack* pStack, int privat) ///tests CBotToken token("this"); inst->SetToken(&token); - ((CBotExprVar*)inst)->m_nIdent = -2; // identificator for this + ((CBotExprVar*)inst)->m_nIdent = -2; // identificator for this - CBotFieldExpr* i = new CBotFieldExpr(); // new element - i->SetToken( p ); // keeps the name of the token + CBotFieldExpr* i = new CBotFieldExpr(); // new element + i->SetToken(p); // keeps the name of the token i->SetUniqNum(ident); - inst->AddNext3(i); // added after + inst->AddNext3(i); // added after } - p = p->GivNext(); // next token + p = p->GivNext(); // next token while (true) { - if ( var->GivType() == CBotTypArrayPointer ) // s'il sagit d'un tableau + if (var->GivType() == CBotTypArrayPointer) { - if ( IsOfType( p, ID_OPBRK ) ) // regarde s'il y a un index + if (IsOfType( p, ID_OPBRK )) // check if there is an aindex { CBotIndexExpr* i = new CBotIndexExpr(); - i->m_expr = CBotExpression::Compile(p, pStk); // compile la formule - inst->AddNext3(i); // ajoute à la chaine + i->m_expr = CBotExpression::Compile(p, pStk); // compile the formula + inst->AddNext3(i); // add to the chain - var = ((CBotVarArray*)var)->GivItem(0,true); // donne le composant [0] + var = ((CBotVarArray*)var)->GivItem(0,true); // gets the component [0] - if ( i->m_expr == NULL ) + if (i->m_expr == NULL) { - pStk->SetError( TX_BADINDEX, p->GivStart() ); + pStk->SetError(TX_BADINDEX, p->GivStart()); goto err; } - if ( !pStk->IsOk() || !IsOfType( p, ID_CLBRK ) ) + if (!pStk->IsOk() || !IsOfType( p, ID_CLBRK )) { - pStk->SetError( TX_CLBRK, p->GivStart() ); + pStk->SetError(TX_CLBRK, p->GivStart()); goto err; } continue; } - //// pStk->SetError( TX_OPBRK, p->GivStart() ); } - if ( var->GivType(1) == CBotTypPointer ) // pour les classes + if (var->GivType(1) == CBotTypPointer) // for classes { - if ( IsOfType(p, ID_DOT) ) + if (IsOfType(p, ID_DOT)) { CBotToken* pp = p; - if ( p->GivType() == TokenTypVar ) // doit être un nom + if (p->GivType() == TokenTypVar) // must be a name { - if ( p->GivNext()->GivType() == ID_OPENPAR )// un appel de méthode ? + if (p->GivNext()->GivType() == ID_OPENPAR) // a method call? { CBotInstr* i = CBotInstrMethode::Compile(p, pStk, var); - if ( !pStk->IsOk() ) goto err; - inst->AddNext3(i); // ajoute à la suite + if (!pStk->IsOk()) goto err; + inst->AddNext3(i); // added after return pStack->Return(inst, pStk); } else { - CBotFieldExpr* i = new CBotFieldExpr(); // nouvel élément - i->SetToken( pp ); // garde le nom du token - inst->AddNext3(i); // ajoute à la suite - var = var->GivItem(p->GivString()); // récupère l'item correpondant - if ( var != NULL ) + CBotFieldExpr* i = new CBotFieldExpr(); // new element + i->SetToken(pp); // keeps the name of the token + inst->AddNext3(i); // add after + var = var->GivItem(p->GivString()); // get item correspondent + if (var != NULL) { i->SetUniqNum(var->GivUniqNum()); if ( var->IsPrivate() && !pStk->GivBotCall()->m_bCompileClass) { - pStk->SetError( TX_PRIVATE, pp ); + pStk->SetError(TX_PRIVATE, pp); goto err; } } } - if ( var != NULL ) + if (var != NULL) { - p = p->GivNext(); // saute le nom + p = p->GivNext(); // skips the name continue; } - pStk->SetError( TX_NOITEM, p ); + pStk->SetError(TX_NOITEM, p); goto err; } - pStk->SetError( TX_DOT, p->GivStart() ); + pStk->SetError(TX_DOT, p->GivStart()); goto err; } } @@ -3217,8 +3169,8 @@ CBotInstr* CBotExprVar::Compile(CBotToken* &p, CBotCStack* pStack, int privat) break; } - pStk->SetCopyVar(var); // place une copie de la variable sur la pile (pour le type) - if ( pStk->IsOk() ) return pStack->Return(inst, pStk); + pStk->SetCopyVar(var); // place the copy of the variable on the stack (for type) + if (pStk->IsOk()) return pStack->Return(inst, pStk); } pStk->SetError(TX_UNDEFVAR, p); err: @@ -3236,34 +3188,35 @@ CBotInstr* CBotExprVar::CompileMethode(CBotToken* &p, CBotCStack* pStack) pStk->SetStartError(pp->GivStart()); - // est-ce un nom de variable ? + // is it a variable ? if (pp->GivType() == TokenTypVar) { CBotToken pthis("this"); CBotVar* var = pStk->FindVar(pthis); - if ( var == 0 ) return pStack->Return(NULL, pStk); + if (var == 0) return pStack->Return(NULL, pStk); + + CBotInstr* inst = new CBotExprVar(); + + // this is an element of the current class + // adds the equivalent of this. before - CBotInstr* inst = new CBotExprVar(); // crée l'objet - - // il s'agit d'un élement de la classe courante - // ajoute l'équivalent d'un this. devant inst->SetToken(&pthis); - ((CBotExprVar*)inst)->m_nIdent = -2; // ident pour this + ((CBotExprVar*)inst)->m_nIdent = -2; // ident for this CBotToken* pp = p; - if ( pp->GivType() == TokenTypVar ) // doit être un nom + if (pp->GivType() == TokenTypVar) { - if ( pp->GivNext()->GivType() == ID_OPENPAR ) // un appel de méthode ? + if (pp->GivNext()->GivType() == ID_OPENPAR) // a method call? { CBotInstr* i = CBotInstrMethode::Compile(pp, pStk, var); - if ( pStk->IsOk() ) + if (pStk->IsOk()) { - inst->AddNext3(i); // ajoute à la suite - p = pp; // instructions passées + inst->AddNext3(i); // add after + p = pp; // previous instruction return pStack->Return(inst, pStk); } - pStk->SetError(0,0); // l'erreur n'est pas traitée ici + pStk->SetError(0,0); // the error is not adressed here } } delete inst; @@ -3272,77 +3225,71 @@ CBotInstr* CBotExprVar::CompileMethode(CBotToken* &p, CBotCStack* pStack) } -// exécute, rend la valeur d'une variable +// execute, making the value of a variable bool CBotExprVar::Execute(CBotStack* &pj) { CBotVar* pVar = NULL; CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return true; - -// if ( pile->IfStep() ) return false; CBotStack* pile1 = pile; - if ( pile1->GivState() == 0 ) + if (pile1->GivState() == 0) { - if ( !ExecuteVar(pVar, pile, NULL, true) ) return false; // récupère la variable selon champs et index -// DEBUG("CBotExprVar::Execute", 1 , pj); + if (!ExecuteVar(pVar, pile, NULL, true)) return false; // Get the variable fields and indexes according - if ( pVar ) pile1->SetCopyVar(pVar); // la place une copie sur la pile + if (pVar) pile1->SetCopyVar(pVar); // place a copy on the stack else { -//-- pile1->SetVar(NULL); // la pile contient déjà le resultat (méthode) return pj->Return(pile1); } pile1->IncState(); } - pVar = pile1->GivVar(); // récupère si interrompu + pVar = pile1->GivVar(); - if ( pVar == NULL ) + if (pVar == NULL) { -// pile1->SetError(TX_NULLPT, &m_token); return pj->Return(pile1); } - if ( pVar->GivInit() == IS_UNDEF ) + if (pVar->GivInit() == IS_UNDEF) { CBotToken* pt = &m_token; - while ( pt->GivNext() != NULL ) pt = pt->GivNext(); + while (pt->GivNext() != NULL) pt = pt->GivNext(); pile1->SetError(TX_NOTINIT, pt); return pj->Return(pile1); } - return pj->Return(pile1); // opération faite + return pj->Return(pile1); // operation completed } void CBotExprVar::RestoreState(CBotStack* &pj, bool bMain) { - if ( !bMain ) return; + if (!bMain) return; CBotStack* pile = pj->RestoreStack(this); - if ( pile == NULL ) return; + if (pile == NULL) return; CBotStack* pile1 = pile; - if ( pile1->GivState() == 0 ) + if (pile1->GivState() == 0) { - RestoreStateVar(pile, bMain); // récupère la variable selon champs et index + RestoreStateVar(pile, bMain); // retrieves the variable fields and indexes according return; } } -// retrouve une variable à l'exécution +// fetch a variable at runtime bool CBotExprVar::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToken, bool bStep) { CBotStack* pile = pj; - pj = pj->AddStack( this ); + pj = pj->AddStack(this); - if ( bStep && m_nIdent>0 && pj->IfStep() ) return false; + if (bStep && m_nIdent>0 && pj->IfStep()) return false; - pVar = pj->FindVar(m_nIdent, true); // cherche la variable avec mise à jour si nécessaire - if ( pVar == NULL ) + pVar = pj->FindVar(m_nIdent, true); // tries with the variable update if necessary + if (pVar == NULL) { #ifdef _DEBUG ASM_TRAP(); @@ -3352,61 +3299,60 @@ bool CBotExprVar::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToke } if ( m_next3 != NULL && !m_next3->ExecuteVar(pVar, pj, &m_token, bStep, false) ) - return false; // Champs d'une instance, tableau, méthode ? + return false; // field of an instance, table, methode - return pile->ReturnKeep( pj ); // ne rend pas la pile mais récupère le résultat si une méthode a été appelée + return pile->ReturnKeep(pj); // does not put on stack but get the result if a method was called } -// retrouve une variable à l'exécution +// fetch variable at runtime void CBotExprVar::RestoreStateVar(CBotStack* &pj, bool bMain) { - pj = pj->RestoreStack( this ); - if ( pj == NULL ) return; + pj = pj->RestoreStack(this); + if (pj == NULL) return; - if ( m_next3 != NULL ) + if (m_next3 != NULL) m_next3->RestoreStateVar(pj, bMain); } ////////////////////////////////////////////////////////////////////////////////////////// -// compile une liste de paramètres +// compile a list of parameters CBotInstr* CompileParams(CBotToken* &p, CBotCStack* pStack, CBotVar** ppVars) { bool first = true; - CBotInstr* ret = NULL; // pour la liste à retourner + CBotInstr* ret = NULL; // to return to the list -// pStack->SetStartError(p->GivStart()); CBotCStack* pile = pStack; int i = 0; - if ( IsOfType(p, ID_OPENPAR) ) + if (IsOfType(p, ID_OPENPAR)) { int start, end; if (!IsOfType(p, ID_CLOSEPAR)) while (true) { start = p->GivStart(); - pile = pile->TokenStack(); // garde les résultats sur la pile + pile = pile->TokenStack(); // keeps the result on the stack - if ( first ) pStack->SetStartError(start); + if (first) pStack->SetStartError(start); first = false; CBotInstr* param = CBotExpression::Compile(p, pile); end = p->GivStart(); - if ( !pile->IsOk() ) + if (!pile->IsOk()) { return pStack->Return(NULL, pile); } - if ( ret == NULL ) ret = param; - else ret->AddNext(param); // construit la liste + if (ret == NULL) ret = param; + else ret->AddNext(param); // construct the list - if ( param != NULL ) + if (param != NULL) { - if ( pile->GivTypResult().Eq(99) ) + if (pile->GivTypResult().Eq(99)) { delete pStack->TokenStack(); pStack->SetError(TX_VOID, p->GivStart()); @@ -3416,7 +3362,7 @@ CBotInstr* CompileParams(CBotToken* &p, CBotCStack* pStack, CBotVar** ppVars) ppVars[i]->GivToken()->SetPos(start, end); i++; - if (IsOfType(p, ID_COMMA)) continue; // saute la virgule + if (IsOfType(p, ID_COMMA)) continue; // skips the comma if (IsOfType(p, ID_CLOSEPAR)) break; } @@ -3433,13 +3379,12 @@ CBotInstr* CompileParams(CBotToken* &p, CBotCStack* pStack, CBotVar** ppVars) ////////////////////////////////////////////////////////////////////////////////////// -// compile un appel d'une méthode +// compile a method call CBotInstrMethode::CBotInstrMethode() { m_Parameters = NULL; m_MethodeIdent = 0; -// m_nThisIdent = 0; name = "CBotInstrMethode"; } @@ -3451,30 +3396,28 @@ CBotInstrMethode::~CBotInstrMethode() CBotInstr* CBotInstrMethode::Compile(CBotToken* &p, CBotCStack* pStack, CBotVar* var) { CBotInstrMethode* inst = new CBotInstrMethode(); - inst->SetToken(p); // token correspondant - -// inst->m_nThisIdent = CBotVar::NextUniqNum(); + inst->SetToken(p); // corresponding token - if ( NULL != var ) + if (NULL != var) { CBotToken* pp = p; p = p->GivNext(); - if ( p->GivType() == ID_OPENPAR ) + if (p->GivType() == ID_OPENPAR) { inst->m_NomMethod = pp->GivString(); - // compile la liste des paramètres + // compiles the list of parameters CBotVar* ppVars[1000]; inst->m_Parameters = CompileParams(p, pStack, ppVars); - if ( pStack->IsOk() ) + if (pStack->IsOk()) { - CBotClass* pClass = var->GivClass(); // pointeur à la classe - inst->m_ClassName = pClass->GivName(); // le nom de la classe + CBotClass* pClass = var->GivClass(); // pointer to the class + inst->m_ClassName = pClass->GivName(); // name of the class CBotTypResult r = pClass->CompileMethode(inst->m_NomMethod, var, ppVars, pStack, inst->m_MethodeIdent); - delete pStack->TokenStack(); // libères les paramètres encore sur la pile + delete pStack->TokenStack(); // release parameters on the stack inst->m_typRes = r; if (inst->m_typRes.GivType() > 20) @@ -3483,13 +3426,12 @@ CBotInstr* CBotInstrMethode::Compile(CBotToken* &p, CBotCStack* pStack, CBotVar* delete inst; return NULL; } - // met un résultat sur la pile pour avoir quelque chose + // put the result on the stack to have something if (inst->m_typRes.GivType() > 0) { CBotVar* pResult = CBotVar::Create("", inst->m_typRes); if (inst->m_typRes.Eq(CBotTypClass)) { -// CBotClass* pClass = CBotClass::Find(inst->m_RetClassName); pResult->SetClass(inst->m_typRes.GivClass()); } pStack->SetVar(pResult); @@ -3500,39 +3442,36 @@ CBotInstr* CBotInstrMethode::Compile(CBotToken* &p, CBotCStack* pStack, CBotVar* return NULL; } } - pStack->SetError( 1234, p ); + pStack->SetError(1234, p); delete inst; return NULL; } -// exécute l'appel de méthode +// execute the method call bool CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToken, bool bStep, bool bExtend) { CBotVar* ppVars[1000]; - CBotStack* pile1 = pj->AddStack(this, true); // une place pour la copie de This -// if ( pile1 == EOX ) return true; + CBotStack* pile1 = pj->AddStack(this, true); // a place for the copy of This -// DEBUG( "CBotInstrMethode::ExecuteVar", 0, pj ); - - if ( pVar->GivPointer() == NULL ) + if (pVar->GivPointer() == NULL) { - pj->SetError( TX_NULLPT, prevToken ); + pj->SetError(TX_NULLPT, prevToken); } - if ( pile1->IfStep() ) return false; + if (pile1->IfStep()) return false; - CBotStack* pile2 = pile1->AddStack(); // et pour les paramètres à venir + CBotStack* pile2 = pile1->AddStack(); // for the next parameters if ( pile1->GivState() == 0) { CBotVar* pThis = CBotVar::Create(pVar); pThis->Copy(pVar); - // la valeur de This doit être prise avant l'évaluation des paramètres - // Test.Action( Test = Autre ); - // Action doit agir sur la valeur avant Test = Autre !! + // this value should be taken before the evaluation parameters + // Test.Action (Test = Other); + // action must act on the value before test = Other! + pThis->SetName("this"); -// pThis->SetUniqNum(m_nThisIdent); pThis->SetUniqNum(-2); pile1->AddVar(pThis); pile1->IncState(); @@ -3540,18 +3479,19 @@ bool CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* pre int i = 0; CBotInstr* p = m_Parameters; - // évalue les paramètres - // et place les valeurs sur la pile - // pour pouvoir être interrompu n'importe quand - if ( p != NULL) while ( true ) + // evaluate the parameters + // and places the values on the stack + // to be interrupted at any time + + if (p != NULL) while ( true) { - if ( pile2->GivState() == 0 ) + if (pile2->GivState() == 0) { - if (!p->Execute(pile2)) return false; // interrompu ici ? - if (!pile2->SetState(1)) return false; // marque spéciale pour reconnaîre les paramètres + if (!p->Execute(pile2)) return false; // interrupted here? + if (!pile2->SetState(1)) return false; // special mark to recognize parameters } - ppVars[i++] = pile2->GivVar(); // construit la liste des pointeurs - pile2 = pile2->AddStack(); // de la place sur la pile pour les résultats + ppVars[i++] = pile2->GivVar(); // construct the list of pointers + pile2 = pile2->AddStack(); // space on the stack for the result p = p->GivNext(); if ( p == NULL) break; } @@ -3563,51 +3503,50 @@ bool CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* pre if (m_typRes.GivType() > 0) pResult = CBotVar::Create("", m_typRes); if (m_typRes.Eq(CBotTypClass)) { -// CBotClass* pClass = CBotClass::Find(m_RetClassName); pResult->SetClass(m_typRes.GivClass()); } CBotVar* pRes = pResult; if ( !pClass->ExecuteMethode(m_MethodeIdent, m_NomMethod, pThis, ppVars, - pResult, pile2, GivToken())) return false; // interrompu + pResult, pile2, GivToken())) return false; if (pRes != pResult) delete pRes; - pVar = NULL; // ne retourne pas une valeur par cela - return pj->Return(pile2); // libère toute la pile + pVar = NULL; // does not return value for this + return pj->Return(pile2); // release the entire stack } void CBotInstrMethode::RestoreStateVar(CBotStack* &pile, bool bMain) { - if ( !bMain ) return; + if (!bMain) return; CBotVar* ppVars[1000]; - CBotStack* pile1 = pile->RestoreStack(this); // une place pour la copie de This - if ( pile1 == NULL ) return; + CBotStack* pile1 = pile->RestoreStack(this); // place for the copy of This + if (pile1 == NULL) return; - CBotStack* pile2 = pile1->RestoreStack(); // et pour les paramètres à venir - if ( pile2 == NULL ) return; + CBotStack* pile2 = pile1->RestoreStack(); // and for the parameters coming + if (pile2 == NULL) return; CBotVar* pThis = pile1->FindVar("this"); -// pThis->SetUniqNum(m_nThisIdent); pThis->SetUniqNum(-2); int i = 0; CBotInstr* p = m_Parameters; - // évalue les paramètres - // et place les valeurs sur la pile - // pour pouvoir être interrompu n'importe quand - if ( p != NULL) while ( true ) + // evaluate the parameters + // and places the values on the stack + // to be interrupted at any time + + if (p != NULL) while ( true) { - if ( pile2->GivState() == 0 ) + if (pile2->GivState() == 0) { - p->RestoreState(pile2, true); // interrompu ici ! + p->RestoreState(pile2, true); // interrupted here! return; } - ppVars[i++] = pile2->GivVar(); // construit la liste des pointeurs + ppVars[i++] = pile2->GivVar(); // construct the list of pointers pile2 = pile2->RestoreStack(); - if ( pile2 == NULL ) return; + if (pile2 == NULL) return; p = p->GivNext(); if ( p == NULL) break; @@ -3627,19 +3566,18 @@ void CBotInstrMethode::RestoreStateVar(CBotStack* &pile, bool bMain) bool CBotInstrMethode::Execute(CBotStack* &pj) { CBotVar* ppVars[1000]; - CBotStack* pile1 = pj->AddStack(this, true); // une place pour la copie de This -// if ( pile1 == EOX ) return true; + CBotStack* pile1 = pj->AddStack(this, true); // place for the copy of This - if ( pile1->IfStep() ) return false; + if (pile1->IfStep()) return false; - CBotStack* pile2 = pile1->AddStack(); // et pour les paramètres à venir + CBotStack* pile2 = pile1->AddStack(); // and for the parameters coming if ( pile1->GivState() == 0) { CBotVar* pThis = pile1->CopyVar(m_token); - // la valeur de This doit être prise avant l'évaluation des paramètres - // Test.Action( Test = Autre ); - // Action doit agir sur la valeur avant Test = Autre !! + // this value should be taken before the evaluation parameters + // Test.Action (Test = Other); + // Action must act on the value before test = Other! pThis->SetName("this"); pile1->AddVar(pThis); pile1->IncState(); @@ -3647,18 +3585,18 @@ bool CBotInstrMethode::Execute(CBotStack* &pj) int i = 0; CBotInstr* p = m_Parameters; - // évalue les paramètres - // et place les valeurs sur la pile - // pour pouvoir être interrompu n'importe quand - if ( p != NULL) while ( true ) + // evaluate the parameters + // and places the values on the stack + // to be interrupted at any time + if (p != NULL) while ( true) { - if ( pile2->GivState() == 0 ) + if (pile2->GivState() == 0) { - if (!p->Execute(pile2)) return false; // interrompu ici ? - if (!pile2->SetState(1)) return false; // marque spéciale pour reconnaîre les paramètres + if (!p->Execute(pile2)) return false; // interrupted here? + if (!pile2->SetState(1)) return false; // special mark to recognize parameters } - ppVars[i++] = pile2->GivVar(); // construit la liste des pointeurs - pile2 = pile2->AddStack(); // de la place sur la pile pour les résultats + ppVars[i++] = pile2->GivVar(); // construct the list of pointers + pile2 = pile2->AddStack(); // space on the stack for the results p = p->GivNext(); if ( p == NULL) break; } @@ -3670,35 +3608,33 @@ bool CBotInstrMethode::Execute(CBotStack* &pj) if (m_typRes.GivType()>0) pResult = CBotVar::Create("", m_typRes); if (m_typRes.Eq(CBotTypClass)) { -// CBotClass* pClass = CBotClass::Find(m_RetClassName); pResult->SetClass(m_typRes.GivClass()); } CBotVar* pRes = pResult; if ( !pClass->ExecuteMethode(m_MethodeIdent, m_NomMethod, pThis, ppVars, - pResult, pile2, GivToken())) return false; // interrompu + pResult, pile2, GivToken())) return false; // interupted - // met la nouvelle valeur de this à la place de l'ancienne variable + // set the new value of this in place of the old variable CBotVar* old = pile1->FindVar(m_token); old->Copy(pThis, false); if (pRes != pResult) delete pRes; - return pj->Return(pile2); // libère toute la pile + return pj->Return(pile2); // release the entire stack } /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// -// compile une instruction "new" +// compile an instruction "new" CBotNew::CBotNew() { name = "CBotNew"; m_Parameters = NULL; m_nMethodeIdent = 0; -// m_nThisIdent = 0; } CBotNew::~CBotNew() @@ -3708,9 +3644,9 @@ CBotNew::~CBotNew() CBotInstr* CBotNew::Compile(CBotToken* &p, CBotCStack* pStack) { CBotToken* pp = p; - if ( !IsOfType(p, ID_NEW) ) return NULL; + if (!IsOfType(p, ID_NEW)) return NULL; - // vérifie que le token est un nom de classe + // verifies that the token is a class name if (p->GivType() != TokenTypVar) return NULL; CBotClass* pClass = CBotClass::Find(p); @@ -3719,11 +3655,6 @@ CBotInstr* CBotNew::Compile(CBotToken* &p, CBotCStack* pStack) pStack->SetError(TX_BADNEW, p); return NULL; } -/* if ( !pClass->m_IsDef ) - { - pStack->SetError(TX_BADNEW, p); - return NULL; - }*/ CBotNew* inst = new CBotNew(); inst->SetToken(pp); @@ -3731,28 +3662,26 @@ CBotInstr* CBotNew::Compile(CBotToken* &p, CBotCStack* pStack) inst->m_vartoken = p; p = p->GivNext(); - // crée l'objet sur le "tas" - // avec un pointeur sur cet objet + // creates the object on the "job" + // with a pointer to the object CBotVar* pVar = CBotVar::Create("", pClass); -// inst->m_nThisIdent = CBotVar::NextUniqNum(); - // fait l'appel du créateur + // do the call of the creator CBotCStack* pStk = pStack->TokenStack(); { - // regarde s'il y a des paramètres + // check if there are parameters CBotVar* ppVars[1000]; inst->m_Parameters = CompileParams(p, pStk, ppVars); - if ( !pStk->IsOk() ) goto error; + if (!pStk->IsOk()) goto error; - // le constructeur existe-il ? -// CBotString noname; + // constructor exist? CBotTypResult r = pClass->CompileMethode(pClass->GivName(), pVar, ppVars, pStk, inst->m_nMethodeIdent); - delete pStk->TokenStack(); // libère le supplément de pile + delete pStk->TokenStack(); // release extra stack int typ = r.GivType(); - // s'il n'y a pas de constructeur, et pas de paramètres non plus, c'est ok - if ( typ == TX_UNDEFCALL && inst->m_Parameters == NULL ) typ = 0; - pVar->SetInit(true); // marque l'instance comme init + // if there is no constructor, and no parameters either, it's ok + if (typ == TX_UNDEFCALL && inst->m_Parameters == NULL) typ = 0; + pVar->SetInit(true); // mark the instance as init if (typ>20) { @@ -3760,14 +3689,14 @@ CBotInstr* CBotNew::Compile(CBotToken* &p, CBotCStack* pStack) goto error; } - // si le constructeur n'existe pas, mais qu'il y a des paramètres + // if the constructor does not exist, but there are parameters if (typ<0 && inst->m_Parameters != NULL) { pStk->SetError(TX_NOCONST, &inst->m_vartoken); goto error; } - // rend le pointeur à l'objet sur la pile + // makes pointer to the object on the stack pStk->SetVar(pVar); return pStack->Return(inst, pStk); } @@ -3776,47 +3705,46 @@ error: return pStack->Return(NULL, pStk); } -// exécute une instruction "new" +// executes instruction "new" bool CBotNew::Execute(CBotStack* &pj) { - CBotStack* pile = pj->AddStack(this); //pile principale -// if ( pile == EOX ) return true; + CBotStack* pile = pj->AddStack(this); //main stack - if ( pile->IfStep() ) return false; + if (pile->IfStep()) return false; - CBotStack* pile1 = pj->AddStack2(); //pile secondaire + CBotStack* pile1 = pj->AddStack2(); //secondary stack CBotVar* pThis = NULL; CBotToken* pt = &m_vartoken; CBotClass* pClass = CBotClass::Find(pt); - // crée la variable "this" de type pointeur à l'objet + // create the variable "this" pointer type to the stack if ( pile->GivState()==0) { - // crée une instance de la classe demandée - // et initialise le pointeur à cet objet + // create an instance of the requested class + // and initialize the pointer to that object + pThis = CBotVar::Create("this", pClass); -// pThis->SetUniqNum( m_nThisIdent ) ; - pThis->SetUniqNum( -2 ) ; + pThis->SetUniqNum(-2) ; - pile1->SetVar(pThis); // la place sur la pile1 + pile1->SetVar(pThis); // place on stack1 pile->IncState(); } - // retrouve le pointeur this si on a été interrompu + // fetch the this pointer if it was interrupted if ( pThis == NULL) { - pThis = pile1->GivVar(); // retrouve le pointeur + pThis = pile1->GivVar(); // find the pointer } - // y a-t-il une assignation ou des paramètres (constructeur) + // is there an assignment or parameters (constructor) if ( pile->GivState()==1) - { - // évalue le constructeur de l'instance + { + // evaluates the constructor of the instance CBotVar* ppVars[1000]; CBotStack* pile2 = pile; @@ -3824,16 +3752,16 @@ bool CBotNew::Execute(CBotStack* &pj) int i = 0; CBotInstr* p = m_Parameters; - // évalue les paramètres - // et place les valeurs sur la pile - // pour pouvoir être interrompu n'importe quand + // evaluate the parameters + // and places the values on the stack + // to be interrupted at any time - if ( p != NULL) while ( true ) + if (p != NULL) while ( true) { - pile2 = pile2->AddStack(); // de la place sur la pile pour les résultats - if ( pile2->GivState() == 0 ) + pile2 = pile2->AddStack(); // space on the stack for the result + if (pile2->GivState() == 0) { - if (!p->Execute(pile2)) return false; // interrompu ici ? + if (!p->Execute(pile2)) return false; // interrupted here? pile2->SetState(1); } ppVars[i++] = pile2->GivVar(); @@ -3842,49 +3770,45 @@ bool CBotNew::Execute(CBotStack* &pj) } ppVars[i] = NULL; - // crée une variable pour le résultat - CBotVar* pResult = NULL; // constructeurs toujours void + // create a variable for the result + CBotVar* pResult = NULL; // constructos still void if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GivName(), pThis, ppVars, - pResult, pile2, GivToken())) return false; // interrompu - - pThis->ConstructorSet(); // signale que le constructeur a été appelé -// pile->Return(pile2); // libère un bout de pile + pResult, pile2, GivToken())) return false; // interrupt -// pile->IncState(); + pThis->ConstructorSet(); // indicates that the constructor has been called } - return pj->Return( pile1 ); // transmet en dessous + return pj->Return(pile1); // passes below } void CBotNew::RestoreState(CBotStack* &pj, bool bMain) { - if ( !bMain ) return; + if (!bMain) return; - CBotStack* pile = pj->RestoreStack(this); //pile principale - if ( pile == NULL ) return; + CBotStack* pile = pj->RestoreStack(this); //primary stack + if (pile == NULL) return; - CBotStack* pile1 = pj->AddStack2(); //pile secondaire + CBotStack* pile1 = pj->AddStack2(); //secondary stack CBotToken* pt = &m_vartoken; CBotClass* pClass = CBotClass::Find(pt); - // crée la variable "this" de type pointeur à l'objet + // create the variable "this" pointer type to the object if ( pile->GivState()==0) { return; } - CBotVar* pThis = pile1->GivVar(); // retrouve le pointeur -// pThis->SetUniqNum( m_nThisIdent ); - pThis->SetUniqNum( -2 ); + CBotVar* pThis = pile1->GivVar(); // find the pointer + pThis->SetUniqNum(-2); - // y a-t-il une assignation ou des paramètres (constructeur) + // is ther an assignment or parameters (constructor) if ( pile->GivState()==1) - { - // évalue le constructeur de l'instance + { + // evaluates the constructor of the instance CBotVar* ppVars[1000]; CBotStack* pile2 = pile; @@ -3892,18 +3816,18 @@ void CBotNew::RestoreState(CBotStack* &pj, bool bMain) int i = 0; CBotInstr* p = m_Parameters; - // évalue les paramètres - // et place les valeurs sur la pile - // pour pouvoir être interrompu n'importe quand + // evaluate the parameters + // and places the values on the stack + // to be interrupted at any time - if ( p != NULL) while ( true ) + if (p != NULL) while ( true) { - pile2 = pile2->RestoreStack(); // de la place sur la pile pour les résultats - if ( pile2 == NULL ) return; + pile2 = pile2->RestoreStack(); // space on the stack for the result + if (pile2 == NULL) return; - if ( pile2->GivState() == 0 ) + if (pile2->GivState() == 0) { - p->RestoreState(pile2, bMain); // interrompu ici ! + p->RestoreState(pile2, bMain); // interrupt here! return; } ppVars[i++] = pile2->GivVar(); @@ -3913,28 +3837,28 @@ void CBotNew::RestoreState(CBotStack* &pj, bool bMain) ppVars[i] = NULL; pClass->RestoreMethode(m_nMethodeIdent, m_vartoken.GivString(), pThis, - ppVars, pile2) ; // interrompu ici ! + ppVars, pile2) ; // interrupt here! } } ///////////////////////////////////////////////////////////// -// regarde si deux résultats sont compatibles pour faire une opération +// check if two results are consistent to make an operation -bool TypeCompatible( CBotTypResult& type1, CBotTypResult& type2, int op ) +bool TypeCompatible(CBotTypResult& type1, CBotTypResult& type2, int op) { int t1 = type1.GivType(); int t2 = type2.GivType(); int max = (t1 > t2) ? t1 : t2; - if ( max == 99 ) return false; // un résultat est void ? + if (max == 99) return false; // result is void? - // cas particulier pour les concaténation de chaînes + // special case for strin concatenation if (op == ID_ADD && max >= CBotTypString) return true; if (op == ID_ASSADD && max >= CBotTypString) return true; if (op == ID_ASS && t1 == CBotTypString) return true; - if ( max >= CBotTypBoolean ) + if (max >= CBotTypBoolean) { if ( (op == ID_EQ || op == ID_NE) && (t1 == CBotTypPointer && t2 == CBotTypNullPointer)) return true; @@ -3954,8 +3878,9 @@ bool TypeCompatible( CBotTypResult& type1, CBotTypResult& type2, int op ) CBotClass* c2 = type2.GivClass(); return c1->IsChildOf(c2) || c2->IsChildOf(c1); - // accepte le caste à l'envers, - // l'opération sera refusée à l'exécution si le pointeur n'est pas compatible + // accept the case in reverse + // the transaction will be denied at runtime if the pointer is not + // compatible } return true; @@ -3966,28 +3891,28 @@ bool TypeCompatible( CBotTypResult& type1, CBotTypResult& type2, int op ) return true; } -// regarde si deux variables sont compatible pour un passage de paramètre +// check if two variables are compatible for parameter passing -bool TypesCompatibles( const CBotTypResult& type1, const CBotTypResult& type2 ) +bool TypesCompatibles(const CBotTypResult& type1, const CBotTypResult& type2) { int t1 = type1.GivType(); int t2 = type2.GivType(); - if ( t1 == CBotTypIntrinsic ) t1 = CBotTypClass; - if ( t2 == CBotTypIntrinsic ) t2 = CBotTypClass; + if (t1 == CBotTypIntrinsic) t1 = CBotTypClass; + if (t2 == CBotTypIntrinsic) t2 = CBotTypClass; int max = (t1 > t2) ? t1 : t2; - if ( max == 99 ) return false; // un résultat est void ? + if (max == 99) return false; // result is void? - if ( max >= CBotTypBoolean ) + if (max >= CBotTypBoolean) { - if ( t2 != t1 ) return false; + if (t2 != t1) return false; - if ( max == CBotTypArrayPointer ) + if (max == CBotTypArrayPointer) return TypesCompatibles(type1.GivTypElem(), type2.GivTypElem()); - if ( max == CBotTypClass || max == CBotTypPointer ) + if (max == CBotTypClass || max == CBotTypPointer) return type1.GivClass() == type2.GivClass() ; return true ; @@ -3997,10 +3922,11 @@ bool TypesCompatibles( const CBotTypResult& type1, const CBotTypResult& type2 ) ///////////////////////////////////////////////////////////////////////////////////// -// Gestion des fichiers +// file management + +// necessary because it is not possible to do the fopen in the main program +// fwrite and fread in a dll or using the FILE * returned. -// nécessaire car il n'est pas possible de faire le fopen dans le programme principal -// et les fwrite ou fread dans une dll en utilisant le FILE* rendu. FILE* fOpen(const char* name, const char* mode) { @@ -4035,34 +3961,3 @@ size_t fRead(void *buffer, size_t length, FILE* filehandle) //////////////////////////////////////// - -#if false - -CBotString num(int n) -{ - CBotString s; - if ( n<0 ) {n = -n; s += "-";} - if ( n > 9 ) - { - s += num(n/10); - } - s += '0' + n%10; - return s; -} - -extern void DEBUG( const char* text, int val, CBotStack* pile ) -{ - CBotProgram* p = pile->GivBotCall(true); - if ( !p->m_bDebugDD ) return; - - FILE* pf = fopen("CbotDebug.txt", "a"); - - fputs( text, pf ); - - CBotString v = " " + num(val) + "\n"; - fputs( v, pf ); - - fclose( pf); -} - -#endif diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h index 6f18be8..d618131 100644 --- a/src/CBot/CBot.h +++ b/src/CBot/CBot.h @@ -13,50 +13,50 @@ // * // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/.//////////////////////////////////////////////////////////////////// -// interpréteur pour le language CBot du jeu COLOBOT +/** + * \file CBot.h + * \brief Interpreter of the language CBot for COLOBOT game + */ -// dernière révision : 03/10/2002 DD - -#define EXTENDS true #include "resource.h" -#include "CBotDll.h" // définitions publiques -#include "CBotToken.h" // gestion des tokens +#include "CBotDll.h" // public definitions +#include "CBotToken.h" // token management -#define STACKRUN true // reprise de l'exécution direct sur une routine suspendue -#define STACKMEM true // préréserve la mémoire pour la pile d'exécution -#define MAXSTACK 990 // taille du stack réservé +#define STACKRUN true /// \def return execution directly on a suspended routine +#define STACKMEM true /// \def preserve memory for the execution stack +#define MAXSTACK 990 /// \def stack size reserved -#define EOX (CBotStack*)-1 // marqueur condition spéciale +#define EOX (CBotStack*)-1 /// \def tag special condition // fix for MSVC instruction __asm int 3 (setting a trap) #ifdef __MINGW32__ -#define ASM_TRAP() asm("int $3"); +#define ASM_TRAP() asm("int $3"); #else -#define ASM_TRAP() __asm int 3; +#define ASM_TRAP() __asm int 3; #endif ///////////////////////////////////////////////////////////////////// -// résumé des classes utilisées, définies ci-après - -class CBotCompExpr; // une expression telle que - // () <= () -class CBotAddExpr; // une expression telle que - // () + () -class CBotParExpr; // un élément de base ou entre parenthèse - // Toto.truc - // 12.5 - // "chaine" - // ( expression ) -class CBotExprVar; // un nom de variable tel que - // Toto - // chose.truc.machin -class CBotWhile; // while (...) {...}; -class CBotIf; // if (...) {...} else {...} -class CBotDefParam; // liste de paramètres d'une fonction -class CBotRepeat; // repeat (nb) {...} +// forward declaration + +class CBotCompExpr; // an expression like + // () <= () +class CBotAddExpr; // an expression like + // () + () +class CBotParExpr; // basic type or instruction in parenthesis + // Toto.truc + // 12.5 + // "string" + // ( expression ) +class CBotExprVar; // a variable name as + // Toto + // chose.truc.machin +class CBotWhile; // while (...) {...}; +class CBotIf; // if (...) {...} else {...} +class CBotDefParam; // paramerer list of a function +class CBotRepeat; // repeat (nb) {...} @@ -65,139 +65,232 @@ class CBotRepeat; // repeat (nb) {...} //////////////////////////////////////////////////////////////////////// // actually, externally, the only thing he can do -// this is to create an instance of a stack +// is to create an instance of a stack // to use for routine CBotProgram :: Execute (CBotStack) +/**\class CBotStack + * \brief Management of the execution stack. + * \brief Actually the only thing it can do is to create an instance of a stack + * \brief to use for routine CBotProgram :: Execute(CBotStack)*/ class CBotStack { -private: - CBotStack* m_next; - CBotStack* m_next2; - CBotStack* m_prev; - friend class CBotInstArray; - -#ifdef _DEBUG - int m_index; +public: +#if STACKMEM + /** + * \brief FirstStack Allocate first stack + * \return pointer to created stack + */ + static CBotStack * FirstStack(); + + /** \brief Delete Remove current stack */ + void Delete(); #endif - int m_state; - int m_step; - static int m_error; - static int m_start; - static int m_end; - static - CBotVar* m_retvar; // résultat d'un return - - CBotVar* m_var; // résultat des opérations - CBotVar* m_listVar; // les variables déclarées à ce niveau - - bool m_bBlock; // fait partie d'un bloc (variables sont locales à ce bloc) - bool m_bOver; // limites de la pile ? -// bool m_bDontDelete; // spécial, ne pas détruire les variables au delete - CBotProgram* m_prog; // les fonctions définies par user - - static - int m_initimer; - static - int m_timer; - static - CBotString m_labelBreak; - static - void* m_pUser; - - CBotInstr* m_instr; // l'instruction correspondante - bool m_bFunc; // une entrée d'une fonction ? - CBotCall* m_call; // point de reprise dans un call extern - friend class CBotTry; -public: -#if STACKMEM - static - CBotStack* FirstStack(); - void Delete(); + /** + * \brief CBotStack Constructor of the stack + * \param ppapa Not used. + */ + CBotStack(CBotStack* ppapa); + + + /** \brief ~CBotStack Destructor */ + ~CBotStack(); + + /** + * \brief StackOver Check if end of stack is reached + * \return true if end of stack + */ + bool StackOver(); + + /** + * \brief GivError Get error number of the stack + * \param [out] start beginning of the stack + * \param [out] end end of stack + * \return error number + */ + int GivError(int& start, int& end); + + /** + * \brief GivError Get error number + * \return eror number + */ + int GivError();// rend le numéro d'erreur retourné + + /** + * \brief Reset Reset error at and set user + * \param [in] pUser User of stack + */ + void Reset(void* pUser); + + /** + * \brief SetType Determines the type. + * \param type Type of instruction on the stack. + */ + void SetType(CBotTypResult& type); + + /** + * \brief GivType Get the type of value on the stack. + * \param [in] mode Used when getting class type (1 gives pointer, 2 gives intrinsic). + * \return Type number. + */ + int GivType(int mode = 0); + + /** + * \brief Gives the type of complete value on the stack. + * \param [in] mode Used when getting class type (1 gives pointer, 2 gives intrinsic). + * \return Type of an element. + */ + CBotTypResult GivTypResult(int mode = 0); + + /** + * \brief Adds a local variable. + * \param [in] p Variable to be added. + */ + void AddVar(CBotVar* p); + + /** + * \brief Fetch a variable by its token. + * \brief This may be a composite variable + * \param [in] pToken Token upon which search is performed + * \param [in] bUpdate Not used. Probably need to be removed + * \param [in] bModif Not used. Probably need to be removed + * \return Found variable + */ + CBotVar* FindVar(CBotToken* &pToken, bool bUpdate = false, + bool bModif = false); + + /** + * \brief Fetch a variable by its token. + * \brief This may be a composite variable + * \param [in] pToken Token upon which search is performed + * \param [in] bUpdate Not used. Probably need to be removed + * \param [in] bModif Not used. Probably need to be removed + * \return Found variable + */ + CBotVar* FindVar(CBotToken& Token, bool bUpdate = false, + bool bModif = false); + + /** + * \brief Fetch variable by its name + * \param [in] name Name of variable to find + * \return Found variable + */ + CBotVar* FindVar(const char* name); + + /** + * \brief Fetch a variable on the stack according to its identification number + * \brief This is faster than comparing names + * \param [in] ident Identifier of a variable + * \param [in] bUpdate Not used. Probably need to be removed + * \param [in] bModif Not used. Probably need to be removed + * \return Found variable + */ + CBotVar* FindVar(long ident, bool bUpdate = false, + bool bModif = false); + + /** + * \brief Find variable by its token and returns a copy of it. + * \param Token Token upon which search is performed + * \param bUpdate Not used. + * \return Found variable, NULL if not found + */ + CBotVar* CopyVar(CBotToken& Token, bool bUpdate = false); + + + CBotStack* AddStack(CBotInstr* instr = NULL, bool bBlock = false); // étend le stack + CBotStack* AddStackEOX(CBotCall* instr = NULL, bool bBlock = false); // étend le stack + CBotStack* RestoreStack(CBotInstr* instr = NULL); + CBotStack* RestoreStackEOX(CBotCall* instr = NULL); + + CBotStack* AddStack2(bool bBlock = false); // étend le stack + bool Return(CBotStack* pFils); // transmet le résultat au dessus + bool ReturnKeep(CBotStack* pFils); // transmet le résultat sans réduire la pile + bool BreakReturn(CBotStack* pfils, const char* name = NULL); + // en cas de break éventuel + bool IfContinue(int state, const char* name); + // ou de "continue" + + bool IsOk(); + + bool SetState(int n, int lim = -10); // sélectionne un état + int GivState(); // dans quel état j'ère ? + bool IncState(int lim = -10); // passe à l'état suivant + bool IfStep(); // faire du pas à pas ? + bool Execute(); + + void SetVar( CBotVar* var ); + void SetCopyVar( CBotVar* var ); + CBotVar* GivVar(); + CBotVar* GivCopyVar(); + CBotVar* GivPtVar(); + bool GivRetVar(bool bRet); + long GivVal(); + + void SetStartError(int pos); + void SetError(int n, CBotToken* token = NULL); + void SetPosError(CBotToken* token); + void ResetError(int n, int start, int end); + void SetBreak(int val, const char* name); + + void SetBotCall(CBotProgram* p); + CBotProgram* GivBotCall(bool bFirst = false); + void* GivPUser(); + bool GivBlock(); + + + bool ExecuteCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotTypResult& rettype); + void RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar); + + bool SaveState(FILE* pf); + bool RestoreState(FILE* pf, CBotStack* &pStack); + + static + void SetTimer(int n); + + void GetRunPos(const char* &FunctionName, int &start, int &end); + CBotVar* GivStackVars(const char* &FunctionName, int level); + + int m_temp; + +private: + CBotStack* m_next; + CBotStack* m_next2; + CBotStack* m_prev; + friend class CBotInstArray; + +#ifdef _DEBUG + int m_index; #endif - CBotStack(CBotStack* ppapa); - ~CBotStack(); - bool StackOver(); - - int GivError(int& start, int& end); - int GivError(); // rend le numéro d'erreur retourné - - void Reset(void* pUser); // plus d'erreur, timer au début - void SetType(CBotTypResult& type); // détermine le type - int GivType(int mode = 0); // donne le type de valeur sur le stack - CBotTypResult GivTypResult(int mode = 0); // donne le type complet de valeur sur le stack - -// void AddVar(CBotVar* p, bool bDontDelete=false); // ajoute une variable locale - void AddVar(CBotVar* p); // ajoute une variable locale -// void RestoreVar(CBotVar* pVar); - - CBotVar* FindVar(CBotToken* &p, bool bUpdate = false, - bool bModif = false); // trouve une variable - CBotVar* FindVar(CBotToken& Token, bool bUpdate = false, - bool bModif = false); - CBotVar* FindVar(const char* name); - CBotVar* FindVar(long ident, bool bUpdate = false, - bool bModif = false); - - CBotVar* CopyVar(CBotToken& Token, bool bUpdate = false); // trouve et rend une copie - - - CBotStack* AddStack(CBotInstr* instr = NULL, bool bBlock = false); // étend le stack - CBotStack* AddStackEOX(CBotCall* instr = NULL, bool bBlock = false); // étend le stack - CBotStack* RestoreStack(CBotInstr* instr = NULL); - CBotStack* RestoreStackEOX(CBotCall* instr = NULL); - - CBotStack* AddStack2(bool bBlock = false); // étend le stack - bool Return(CBotStack* pFils); // transmet le résultat au dessus - bool ReturnKeep(CBotStack* pFils); // transmet le résultat sans réduire la pile - bool BreakReturn(CBotStack* pfils, const char* name = NULL); - // en cas de break éventuel - bool IfContinue(int state, const char* name); - // ou de "continue" - - bool IsOk(); - - bool SetState(int n, int lim = -10); // sélectionne un état - int GivState(); // dans quel état j'ère ? - bool IncState(int lim = -10); // passe à l'état suivant - bool IfStep(); // faire du pas à pas ? - bool Execute(); - - void SetVar( CBotVar* var ); - void SetCopyVar( CBotVar* var ); - CBotVar* GivVar(); - CBotVar* GivCopyVar(); - CBotVar* GivPtVar(); - bool GivRetVar(bool bRet); - long GivVal(); - - void SetStartError(int pos); - void SetError(int n, CBotToken* token = NULL); - void SetPosError(CBotToken* token); - void ResetError(int n, int start, int end); - void SetBreak(int val, const char* name); - - void SetBotCall(CBotProgram* p); - CBotProgram* GivBotCall(bool bFirst = false); - void* GivPUser(); - bool GivBlock(); - - -// bool ExecuteCall(CBotToken* token, CBotVar** ppVar, CBotTypResult& rettype); - bool ExecuteCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotTypResult& rettype); - void RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar); - - bool SaveState(FILE* pf); - bool RestoreState(FILE* pf, CBotStack* &pStack); - - static - void SetTimer(int n); - - void GetRunPos(const char* &FunctionName, int &start, int &end); - CBotVar* GivStackVars(const char* &FunctionName, int level); - - int m_temp; + int m_state; + int m_step; + static int m_error; + static int m_start; + static int m_end; + static + CBotVar* m_retvar; // résultat d'un return + + CBotVar* m_var; // résultat des opérations + CBotVar* m_listVar; // les variables déclarées à ce niveau + + bool m_bBlock; // fait partie d'un bloc (variables sont locales à ce bloc) + bool m_bOver; // limites de la pile ? +// bool m_bDontDelete; // spécial, ne pas détruire les variables au delete + CBotProgram* m_prog; // les fonctions définies par user + + static + int m_initimer; + static + int m_timer; + static + CBotString m_labelBreak; + static + void* m_pUser; + + CBotInstr* m_instr; // l'instruction correspondante + bool m_bFunc; // une entrée d'une fonction ? + CBotCall* m_call; // point de reprise dans un call extern + friend class CBotTry; }; // les routines inline doivent être déclarées dans le fichier .h @@ -214,7 +307,7 @@ inline int CBotStack::GivState() inline int CBotStack::GivError() { - return m_error; + return m_error; } //////////////////////////////////////////////////////////////////////// @@ -225,70 +318,70 @@ inline int CBotStack::GivError() class CBotCStack { private: - CBotCStack* m_next; - CBotCStack* m_prev; + CBotCStack* m_next; + CBotCStack* m_prev; - static - int m_error; - static - int m_end; - int m_start; + static + int m_error; + static + int m_end; + int m_start; - CBotVar* m_var; // résultat des opérations + CBotVar* m_var; // résultat des opérations - bool m_bBlock; // fait partie d'un bloc (variables sont locales à ce bloc) - CBotVar* m_listVar; + bool m_bBlock; // fait partie d'un bloc (variables sont locales à ce bloc) + CBotVar* m_listVar; - static - CBotProgram* m_prog; // liste des fonctions compilées - static - CBotTypResult m_retTyp; -// static -// CBotToken* m_retClass; + static + CBotProgram* m_prog; // liste des fonctions compilées + static + CBotTypResult m_retTyp; +// static +// CBotToken* m_retClass; public: - CBotCStack(CBotCStack* ppapa); - ~CBotCStack(); - - bool IsOk(); - int GivError(); - int GivError(int& start, int& end); - // rend le numéro d'erreur retourné - - void SetType(CBotTypResult& type);// détermine le type - CBotTypResult GivTypResult(int mode = 0); // donne le type de valeur sur le stack - int GivType(int mode = 0); // donne le type de valeur sur le stack - CBotClass* GivClass(); // donne la classe de la valeur sur le stack - - void AddVar(CBotVar* p); // ajoute une variable locale - CBotVar* FindVar(CBotToken* &p); // trouve une variable - CBotVar* FindVar(CBotToken& Token); - bool CheckVarLocal(CBotToken* &pToken); - CBotVar* CopyVar(CBotToken& Token); // trouve et rend une copie - - CBotCStack* TokenStack(CBotToken* pToken = NULL, bool bBlock = false); - CBotInstr* Return(CBotInstr* p, CBotCStack* pParent); // transmet le résultat au dessus - CBotFunction* ReturnFunc(CBotFunction* p, CBotCStack* pParent); // transmet le résultat au dessus - - void SetVar( CBotVar* var ); - void SetCopyVar( CBotVar* var ); - CBotVar* GivVar(); - - void SetStartError(int pos); - void SetError(int n, int pos); - void SetError(int n, CBotToken* p); - void ResetError(int n, int start, int end); - - void SetRetType(CBotTypResult& type); - CBotTypResult GivRetType(); - -// void SetBotCall(CBotFunction* &pFunc); - void SetBotCall(CBotProgram* p); - CBotProgram* GivBotCall(); - CBotTypResult CompileCall(CBotToken* &p, CBotVar** ppVars, long& nIdent); - bool CheckCall(CBotToken* &pToken, CBotDefParam* pParam); - - bool NextToken(CBotToken* &p); + CBotCStack(CBotCStack* ppapa); + ~CBotCStack(); + + bool IsOk(); + int GivError(); + int GivError(int& start, int& end); + // rend le numéro d'erreur retourné + + void SetType(CBotTypResult& type);// détermine le type + CBotTypResult GivTypResult(int mode = 0); // donne le type de valeur sur le stack + int GivType(int mode = 0); // donne le type de valeur sur le stack + CBotClass* GivClass(); // donne la classe de la valeur sur le stack + + void AddVar(CBotVar* p); // ajoute une variable locale + CBotVar* FindVar(CBotToken* &p); // trouve une variable + CBotVar* FindVar(CBotToken& Token); + bool CheckVarLocal(CBotToken* &pToken); + CBotVar* CopyVar(CBotToken& Token); // trouve et rend une copie + + CBotCStack* TokenStack(CBotToken* pToken = NULL, bool bBlock = false); + CBotInstr* Return(CBotInstr* p, CBotCStack* pParent); // transmet le résultat au dessus + CBotFunction* ReturnFunc(CBotFunction* p, CBotCStack* pParent); // transmet le résultat au dessus + + void SetVar( CBotVar* var ); + void SetCopyVar( CBotVar* var ); + CBotVar* GivVar(); + + void SetStartError(int pos); + void SetError(int n, int pos); + void SetError(int n, CBotToken* p); + void ResetError(int n, int start, int end); + + void SetRetType(CBotTypResult& type); + CBotTypResult GivRetType(); + +// void SetBotCall(CBotFunction* &pFunc); + void SetBotCall(CBotProgram* p); + CBotProgram* GivBotCall(); + CBotTypResult CompileCall(CBotToken* &p, CBotVar** ppVars, long& nIdent); + bool CheckCall(CBotToken* &pToken, CBotDefParam* pParam); + + bool NextToken(CBotToken* &p); }; @@ -300,105 +393,104 @@ extern bool SaveVar(FILE* pf, CBotVar* pVar); class CBotInstr { private: - static - CBotStringArray - m_labelLvl; + static + CBotStringArray + m_labelLvl; protected: - CBotToken m_token; // keeps the token - CBotString name; // debug - CBotInstr* m_next; // linked command - CBotInstr* m_next2b; // second list definition chain - CBotInstr* m_next3; // third list for indices and fields - CBotInstr* m_next3b; // necessary for reporting tables + CBotToken m_token; // keeps the token + CBotString name; // debug + CBotInstr* m_next; // linked command + CBotInstr* m_next2b; // second list definition chain + CBotInstr* m_next3; // third list for indices and fields + CBotInstr* m_next3b; // necessary for reporting tables /* - for example, the following program - int x[]; x[1] = 4; - int y[x[1]][10], z; + for example, the following program + int x[]; x[1] = 4; + int y[x[1]][10], z; is generated - CBotInstrArray - m_next3b-> CBotEmpty - m_next-> - CBotExpression .... - m_next-> - CBotInstrArray - m_next3b-> CBotExpression ('x') ( m_next3-> CBotIndexExpr ('1') ) - m_next3b-> CBotExpression ('10') - m_next2-> 'z' - m_next->... + CBotInstrArray + m_next3b-> CBotEmpty + m_next-> + CBotExpression .... + m_next-> + CBotInstrArray + m_next3b-> CBotExpression ('x') ( m_next3-> CBotIndexExpr ('1') ) + m_next3b-> CBotExpression ('10') + m_next2-> 'z' + m_next->... */ - static - int m_LoopLvl; - friend class CBotClassInst; - friend class CBotInt; - friend class CBotListArray; + static + int m_LoopLvl; + friend class CBotClassInst; + friend class CBotInt; + friend class CBotListArray; public: - CBotInstr(); - virtual - ~CBotInstr(); - -// DllExport//debug - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - static - CBotInstr* CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypResult type, bool first = true); - - virtual - bool Execute(CBotStack* &pj); - virtual - bool Execute(CBotStack* &pj, CBotVar* pVar); - virtual - void RestoreState(CBotStack* &pj, bool bMain); - - virtual - bool ExecuteVar(CBotVar* &pVar, CBotCStack* &pile); - virtual - bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep, bool bExtend); - virtual - void RestoreStateVar(CBotStack* &pile, bool bMain); - - virtual - bool CompCase(CBotStack* &pj, int val); - - void SetToken(CBotToken* p); - int GivTokenType(); - CBotToken* GivToken(); - - void AddNext(CBotInstr* n); - CBotInstr* GivNext(); - void AddNext3(CBotInstr* n); - CBotInstr* GivNext3(); - void AddNext3b(CBotInstr* n); - CBotInstr* GivNext3b(); - - static - void IncLvl(CBotString& label); - static - void IncLvl(); - static - void DecLvl(); - static - bool ChkLvl(const CBotString& label, int type); - - bool IsOfClass(CBotString name); + CBotInstr(); + virtual + ~CBotInstr(); + + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + static + CBotInstr* CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypResult type, bool first = true); + + virtual + bool Execute(CBotStack* &pj); + virtual + bool Execute(CBotStack* &pj, CBotVar* pVar); + virtual + void RestoreState(CBotStack* &pj, bool bMain); + + virtual + bool ExecuteVar(CBotVar* &pVar, CBotCStack* &pile); + virtual + bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep, bool bExtend); + virtual + void RestoreStateVar(CBotStack* &pile, bool bMain); + + virtual + bool CompCase(CBotStack* &pj, int val); + + void SetToken(CBotToken* p); + int GivTokenType(); + CBotToken* GivToken(); + + void AddNext(CBotInstr* n); + CBotInstr* GivNext(); + void AddNext3(CBotInstr* n); + CBotInstr* GivNext3(); + void AddNext3b(CBotInstr* n); + CBotInstr* GivNext3b(); + + static + void IncLvl(CBotString& label); + static + void IncLvl(); + static + void DecLvl(); + static + bool ChkLvl(const CBotString& label, int type); + + bool IsOfClass(CBotString name); }; class CBotWhile : public CBotInstr { private: - CBotInstr* m_Condition; // la condition - CBotInstr* m_Block; // les instructions - CBotString m_label; // une étiquette s'il y a + CBotInstr* m_Condition; // la condition + CBotInstr* m_Block; // les instructions + CBotString m_label; // une étiquette s'il y a public: - CBotWhile(); - ~CBotWhile(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotWhile(); + ~CBotWhile(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotRepeat : public CBotInstr @@ -430,144 +522,144 @@ public: class CBotDo : public CBotInstr { private: - CBotInstr* m_Block; // les instructions - CBotInstr* m_Condition; // la condition - CBotString m_label; // une étiquette s'il y a + CBotInstr* m_Block; // les instructions + CBotInstr* m_Condition; // la condition + CBotString m_label; // une étiquette s'il y a public: - CBotDo(); - ~CBotDo(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotDo(); + ~CBotDo(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotFor : public CBotInstr { private: - CBotInstr* m_Init; // intruction initiale - CBotInstr* m_Test; // la condition de test - CBotInstr* m_Incr; // instruction pour l'incrément - CBotInstr* m_Block; // les instructions - CBotString m_label; // une étiquette s'il y a + CBotInstr* m_Init; // intruction initiale + CBotInstr* m_Test; // la condition de test + CBotInstr* m_Incr; // instruction pour l'incrément + CBotInstr* m_Block; // les instructions + CBotString m_label; // une étiquette s'il y a public: - CBotFor(); - ~CBotFor(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotFor(); + ~CBotFor(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotBreak : public CBotInstr { private: - CBotString m_label; // une étiquette s'il y a + CBotString m_label; // une étiquette s'il y a public: - CBotBreak(); - ~CBotBreak(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotBreak(); + ~CBotBreak(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotReturn : public CBotInstr { private: - CBotInstr* m_Instr; // le paramètre à retourner + CBotInstr* m_Instr; // le paramètre à retourner public: - CBotReturn(); - ~CBotReturn(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotReturn(); + ~CBotReturn(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotSwitch : public CBotInstr { private: - CBotInstr* m_Value; // value à chercher - CBotInstr* m_Block; // les instructions + CBotInstr* m_Value; // value à chercher + CBotInstr* m_Block; // les instructions public: - CBotSwitch(); - ~CBotSwitch(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotSwitch(); + ~CBotSwitch(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotCase : public CBotInstr { private: - CBotInstr* m_Value; // valeur à comparer + CBotInstr* m_Value; // valeur à comparer public: - CBotCase(); - ~CBotCase(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); - bool CompCase(CBotStack* &pj, int val); + CBotCase(); + ~CBotCase(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); + bool CompCase(CBotStack* &pj, int val); }; class CBotCatch : public CBotInstr { private: - CBotInstr* m_Block; // les instructions - CBotInstr* m_Cond; // la condition - CBotCatch* m_next; // le catch suivant - friend class CBotTry; + CBotInstr* m_Block; // les instructions + CBotInstr* m_Cond; // la condition + CBotCatch* m_next; // le catch suivant + friend class CBotTry; public: - CBotCatch(); - ~CBotCatch(); - static - CBotCatch* Compile(CBotToken* &p, CBotCStack* pStack); - bool TestCatch(CBotStack* &pj, int val); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); - void RestoreCondState(CBotStack* &pj, bool bMain); + CBotCatch(); + ~CBotCatch(); + static + CBotCatch* Compile(CBotToken* &p, CBotCStack* pStack); + bool TestCatch(CBotStack* &pj, int val); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); + void RestoreCondState(CBotStack* &pj, bool bMain); }; class CBotTry : public CBotInstr { private: - CBotInstr* m_Block; // les instructions - CBotCatch* m_ListCatch; // les catches - CBotInstr* m_FinalInst; // instruction finale + CBotInstr* m_Block; // les instructions + CBotCatch* m_ListCatch; // les catches + CBotInstr* m_FinalInst; // instruction finale public: - CBotTry(); - ~CBotTry(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotTry(); + ~CBotTry(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotThrow : public CBotInstr { private: - CBotInstr* m_Value; // la valeur à envoyer + CBotInstr* m_Value; // la valeur à envoyer public: - CBotThrow(); - ~CBotThrow(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotThrow(); + ~CBotThrow(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -576,28 +668,28 @@ class CBotStartDebugDD : public CBotInstr private: public: - CBotStartDebugDD(); - ~CBotStartDebugDD(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); + CBotStartDebugDD(); + ~CBotStartDebugDD(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); }; class CBotIf : public CBotInstr { private: - CBotInstr* m_Condition; // la condition - CBotInstr* m_Block; // les instructions - CBotInstr* m_BlockElse; // les instructions + CBotInstr* m_Condition; // la condition + CBotInstr* m_Block; // les instructions + CBotInstr* m_BlockElse; // les instructions public: - CBotIf(); - ~CBotIf(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotIf(); + ~CBotIf(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -606,17 +698,17 @@ public: class CBotInt : public CBotInstr { private: - CBotInstr* m_var; // la variable à initialiser - CBotInstr* m_expr; // la valeur à mettre, s'il y a -/// CBotInstr* m_next; // plusieurs définitions enchaînées + CBotInstr* m_var; // la variable à initialiser + CBotInstr* m_expr; // la valeur à mettre, s'il y a +/// CBotInstr* m_next; // plusieurs définitions enchaînées public: - CBotInt(); - ~CBotInt(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip = false); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotInt(); + ~CBotInt(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip = false); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; // définition d'un tableau @@ -624,19 +716,19 @@ public: class CBotInstArray : public CBotInstr { private: - CBotInstr* m_var; // la variable à initialiser - CBotInstr* m_listass; // liste d'assignations pour le tableau - CBotTypResult - m_typevar; // type d'éléments -// CBotString m_ClassName; + CBotInstr* m_var; // la variable à initialiser + CBotInstr* m_listass; // liste d'assignations pour le tableau + CBotTypResult + m_typevar; // type d'éléments +// CBotString m_ClassName; public: - CBotInstArray(); - ~CBotInstArray(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResult type); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotInstArray(); + ~CBotInstArray(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResult type); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -646,22 +738,22 @@ public: class CBotListArray : public CBotInstr { private: - CBotInstr* m_expr; // expression pour un élément - // les autres sont chaînés avec CBotInstr::m_next3; + CBotInstr* m_expr; // expression pour un élément + // les autres sont chaînés avec CBotInstr::m_next3; public: - CBotListArray(); - ~CBotListArray(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResult type); - bool Execute(CBotStack* &pj, CBotVar* pVar); - void RestoreState(CBotStack* &pj, bool bMain); + CBotListArray(); + ~CBotListArray(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResult type); + bool Execute(CBotStack* &pj, CBotVar* pVar); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotEmpty : public CBotInstr { - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; // définition d'un booléen @@ -669,16 +761,16 @@ class CBotEmpty : public CBotInstr class CBotBoolean : public CBotInstr { private: - CBotInstr* m_var; // la variable à initialiser - CBotInstr* m_expr; // la valeur à mettre, s'il y a + CBotInstr* m_var; // la variable à initialiser + CBotInstr* m_expr; // la valeur à mettre, s'il y a public: - CBotBoolean(); - ~CBotBoolean(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip=false); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotBoolean(); + ~CBotBoolean(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip=false); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -687,16 +779,16 @@ public: class CBotFloat : public CBotInstr { private: - CBotInstr* m_var; // la variable à initialiser - CBotInstr* m_expr; // la valeur à mettre, s'il y a + CBotInstr* m_var; // la variable à initialiser + CBotInstr* m_expr; // la valeur à mettre, s'il y a public: - CBotFloat(); - ~CBotFloat(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip=false); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotFloat(); + ~CBotFloat(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip=false); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; // définition d'un elément string @@ -704,16 +796,16 @@ public: class CBotIString : public CBotInstr { private: - CBotInstr* m_var; // la variable à initialiser - CBotInstr* m_expr; // la valeur à mettre, s'il y a + CBotInstr* m_var; // la variable à initialiser + CBotInstr* m_expr; // la valeur à mettre, s'il y a public: - CBotIString(); - ~CBotIString(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip=false); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotIString(); + ~CBotIString(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip=false); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; // définition d'un elément dans une classe quelconque @@ -721,20 +813,20 @@ public: class CBotClassInst : public CBotInstr { private: - CBotInstr* m_var; // la variable à initialiser - CBotClass* m_pClass; // référence à la classe - CBotInstr* m_Parameters; // les paramètres à évaluer pour le constructeur - CBotInstr* m_expr; // la valeur à mettre, s'il y a - bool m_hasParams; // il y a des paramètres ? - long m_nMethodeIdent; + CBotInstr* m_var; // la variable à initialiser + CBotClass* m_pClass; // référence à la classe + CBotInstr* m_Parameters; // les paramètres à évaluer pour le constructeur + CBotInstr* m_expr; // la valeur à mettre, s'il y a + bool m_hasParams; // il y a des paramètres ? + long m_nMethodeIdent; public: - CBotClassInst(); - ~CBotClassInst(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* pClass = NULL); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotClassInst(); + ~CBotClassInst(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* pClass = NULL); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotCondition : public CBotInstr @@ -743,8 +835,8 @@ private: public: - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); }; @@ -754,18 +846,18 @@ public: class CBotLeftExpr : public CBotInstr { private: - long m_nIdent; + long m_nIdent; public: - CBotLeftExpr(); - ~CBotLeftExpr(); - static - CBotLeftExpr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pStack, CBotStack* array); - - bool ExecuteVar(CBotVar* &pVar, CBotCStack* &pile); - bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep); - void RestoreStateVar(CBotStack* &pile, bool bMain); + CBotLeftExpr(); + ~CBotLeftExpr(); + static + CBotLeftExpr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pStack, CBotStack* array); + + bool ExecuteVar(CBotVar* &pVar, CBotCStack* &pile); + bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep); + void RestoreStateVar(CBotStack* &pile, bool bMain); }; @@ -774,18 +866,18 @@ public: class CBotFieldExpr : public CBotInstr { private: - friend class CBotExpression; - int m_nIdent; + friend class CBotExpression; + int m_nIdent; public: - CBotFieldExpr(); - ~CBotFieldExpr(); - void SetUniqNum(int num); -// static -// CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool ExecuteVar(CBotVar* &pVar, CBotCStack* &pile); - bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep, bool bExtend); - void RestoreStateVar(CBotStack* &pj, bool bMain); + CBotFieldExpr(); + ~CBotFieldExpr(); + void SetUniqNum(int num); +// static +// CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool ExecuteVar(CBotVar* &pVar, CBotCStack* &pile); + bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep, bool bExtend); + void RestoreStateVar(CBotStack* &pj, bool bMain); }; // gestion des index dans les tableaux @@ -793,18 +885,18 @@ public: class CBotIndexExpr : public CBotInstr { private: - CBotInstr* m_expr; // expression pour le calcul de l'index - friend class CBotLeftExpr; - friend class CBotExprVar; + CBotInstr* m_expr; // expression pour le calcul de l'index + friend class CBotLeftExpr; + friend class CBotExprVar; public: - CBotIndexExpr(); - ~CBotIndexExpr(); -// static -// CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool ExecuteVar(CBotVar* &pVar, CBotCStack* &pile); - bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep, bool bExtend); - void RestoreStateVar(CBotStack* &pj, bool bMain); + CBotIndexExpr(); + ~CBotIndexExpr(); +// static +// CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool ExecuteVar(CBotVar* &pVar, CBotCStack* &pile); + bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep, bool bExtend); + void RestoreStateVar(CBotStack* &pj, bool bMain); }; // une expression du genre @@ -814,47 +906,47 @@ public: class CBotExpression : public CBotInstr { private: - CBotLeftExpr* m_leftop; // élément de gauche - CBotInstr* m_rightop; // élément de droite + CBotLeftExpr* m_leftop; // élément de gauche + CBotInstr* m_rightop; // élément de droite public: - CBotExpression(); - ~CBotExpression(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pStack); - void RestoreState(CBotStack* &pj, bool bMain); + CBotExpression(); + ~CBotExpression(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pStack); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotListExpression : public CBotInstr { private: - CBotInstr* m_Expr; // la 1ère expression à évaluer + CBotInstr* m_Expr; // la 1ère expression à évaluer public: - CBotListExpression(); - ~CBotListExpression(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pStack); - void RestoreState(CBotStack* &pj, bool bMain); + CBotListExpression(); + ~CBotListExpression(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pStack); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotLogicExpr : public CBotInstr { private: - CBotInstr* m_condition; // test à évaluer - CBotInstr* m_op1; // élément de gauche - CBotInstr* m_op2; // élément de droite - friend class CBotTwoOpExpr; + CBotInstr* m_condition; // test à évaluer + CBotInstr* m_op1; // élément de gauche + CBotInstr* m_op2; // élément de droite + friend class CBotTwoOpExpr; public: - CBotLogicExpr(); - ~CBotLogicExpr(); -// static -// CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pStack); - void RestoreState(CBotStack* &pj, bool bMain); + CBotLogicExpr(); + ~CBotLogicExpr(); +// static +// CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pStack); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -864,8 +956,8 @@ class CBotBoolExpr : public CBotInstr private: public: - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); }; @@ -878,22 +970,22 @@ class CBotParExpr : public CBotInstr private: public: - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); }; // expression unaire class CBotExprUnaire : public CBotInstr { private: - CBotInstr* m_Expr; // l'expression à évaluer + CBotInstr* m_Expr; // l'expression à évaluer public: - CBotExprUnaire(); - ~CBotExprUnaire(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pStack); - void RestoreState(CBotStack* &pj, bool bMain); + CBotExprUnaire(); + ~CBotExprUnaire(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pStack); + void RestoreState(CBotStack* &pj, bool bMain); }; // toutes les opérations à 2 opérandes @@ -901,15 +993,15 @@ public: class CBotTwoOpExpr : public CBotInstr { private: - CBotInstr* m_leftop; // élément de gauche - CBotInstr* m_rightop; // élément de droite + CBotInstr* m_leftop; // élément de gauche + CBotInstr* m_rightop; // élément de droite public: - CBotTwoOpExpr(); - ~CBotTwoOpExpr(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, int* pOperations = NULL); - bool Execute(CBotStack* &pStack); - void RestoreState(CBotStack* &pj, bool bMain); + CBotTwoOpExpr(); + ~CBotTwoOpExpr(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, int* pOperations = NULL); + bool Execute(CBotStack* &pStack); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -921,10 +1013,10 @@ class CBotBlock : public CBotInstr private: public: - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal = true); - static - CBotInstr* CompileBlkOrInst(CBotToken* &p, CBotCStack* pStack, bool bLocal = false); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal = true); + static + CBotInstr* CompileBlkOrInst(CBotToken* &p, CBotCStack* pStack, bool bLocal = false); }; @@ -932,35 +1024,35 @@ public: class CBotListInstr : public CBotInstr { private: - CBotInstr* m_Instr; // les instructions à faire + CBotInstr* m_Instr; // les instructions à faire public: - CBotListInstr(); - ~CBotListInstr(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal = true); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotListInstr(); + ~CBotListInstr(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal = true); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotInstrCall : public CBotInstr { private: - CBotInstr* m_Parameters; // les paramètres à évaluer -// int m_typeRes; // type du résultat -// CBotString m_RetClassName; // class du résultat - CBotTypResult - m_typRes; // type complet du résultat - long m_nFuncIdent; // id de la fonction + CBotInstr* m_Parameters; // les paramètres à évaluer +// int m_typeRes; // type du résultat +// CBotString m_RetClassName; // class du résultat + CBotTypResult + m_typRes; // type complet du résultat + long m_nFuncIdent; // id de la fonction public: - CBotInstrCall(); - ~CBotInstrCall(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotInstrCall(); + ~CBotInstrCall(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; // un appel d'une méthode @@ -968,25 +1060,25 @@ public: class CBotInstrMethode : public CBotInstr { private: - CBotInstr* m_Parameters; // les paramètres à évaluer -// int m_typeRes; // type du résultat -// CBotString m_RetClassName; // class du résultat - CBotTypResult - m_typRes; // type complet du résultat + CBotInstr* m_Parameters; // les paramètres à évaluer +// int m_typeRes; // type du résultat +// CBotString m_RetClassName; // class du résultat + CBotTypResult + m_typRes; // type complet du résultat - CBotString m_NomMethod; // nom de la méthode - long m_MethodeIdent; // identificateur de la méthode -// long m_nThisIdent; // identificateur pour "this" - CBotString m_ClassName; // nom de la classe + CBotString m_NomMethod; // nom de la méthode + long m_MethodeIdent; // identificateur de la méthode +// long m_nThisIdent; // identificateur pour "this" + CBotString m_ClassName; // nom de la classe public: - CBotInstrMethode(); - ~CBotInstrMethode(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotVar* pVar); - bool Execute(CBotStack* &pj); - bool ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToken, bool bStep, bool bExtend); - void RestoreStateVar(CBotStack* &pj, bool bMain); + CBotInstrMethode(); + ~CBotInstrMethode(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotVar* pVar); + bool Execute(CBotStack* &pj); + bool ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToken, bool bStep, bool bExtend); + void RestoreStateVar(CBotStack* &pj, bool bMain); }; // expression for the variable name @@ -994,53 +1086,53 @@ public: class CBotExprVar : public CBotInstr { private: - long m_nIdent; - friend class CBotPostIncExpr; - friend class CBotPreIncExpr; + long m_nIdent; + friend class CBotPostIncExpr; + friend class CBotPreIncExpr; public: - CBotExprVar(); - ~CBotExprVar(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, int privat=PR_PROTECT); - static - CBotInstr* CompileMethode(CBotToken* &p, CBotCStack* pStack); - - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); - bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep); - bool Execute2Var(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToken, bool bStep); - void RestoreStateVar(CBotStack* &pj, bool bMain); + CBotExprVar(); + ~CBotExprVar(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, int privat=PR_PROTECT); + static + CBotInstr* CompileMethode(CBotToken* &p, CBotCStack* pStack); + + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); + bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep); + bool Execute2Var(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToken, bool bStep); + void RestoreStateVar(CBotStack* &pj, bool bMain); }; class CBotPostIncExpr : public CBotInstr { private: - CBotInstr* m_Instr; - friend class CBotParExpr; + CBotInstr* m_Instr; + friend class CBotParExpr; public: - CBotPostIncExpr(); - ~CBotPostIncExpr(); -// static -// CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotPostIncExpr(); + ~CBotPostIncExpr(); +// static +// CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotPreIncExpr : public CBotInstr { private: - CBotInstr* m_Instr; - friend class CBotParExpr; + CBotInstr* m_Instr; + friend class CBotParExpr; public: - CBotPreIncExpr(); - ~CBotPreIncExpr(); -// static -// CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotPreIncExpr(); + ~CBotPreIncExpr(); +// static +// CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -1048,17 +1140,17 @@ class CBotLeftExprVar : public CBotInstr { private: public: - CBotTypResult - m_typevar; // type de variable déclarée - long m_nIdent; // identificateur unique pour cette variable + CBotTypResult + m_typevar; // type de variable déclarée + long m_nIdent; // identificateur unique pour cette variable public: - CBotLeftExprVar(); - ~CBotLeftExprVar(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotLeftExprVar(); + ~CBotLeftExprVar(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -1067,13 +1159,13 @@ class CBotExprBool : public CBotInstr private: public: - CBotExprBool(); - ~CBotExprBool(); + CBotExprBool(); + ~CBotExprBool(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -1082,11 +1174,11 @@ class CBotExprNull : public CBotInstr private: public: - CBotExprNull(); - ~CBotExprNull(); + CBotExprNull(); + ~CBotExprNull(); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotExprNan : public CBotInstr @@ -1094,29 +1186,29 @@ class CBotExprNan : public CBotInstr private: public: - CBotExprNan(); - ~CBotExprNan(); + CBotExprNan(); + ~CBotExprNan(); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotNew : public CBotInstr { private: - CBotInstr* m_Parameters; // les paramètres à évaluer - long m_nMethodeIdent; -// long m_nThisIdent; - CBotToken m_vartoken; + CBotInstr* m_Parameters; // les paramètres à évaluer + long m_nMethodeIdent; +// long m_nThisIdent; + CBotToken m_vartoken; public: - CBotNew(); - ~CBotNew(); + CBotNew(); + ~CBotNew(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; // expression représentant un nombre @@ -1124,17 +1216,17 @@ public: class CBotExprNum : public CBotInstr { private: - int m_numtype; // et le type de nombre - long m_valint; // valeur pour un int - float m_valfloat; // valeur pour un float + int m_numtype; // et le type de nombre + long m_valint; // valeur pour un int + float m_valfloat; // valeur pour un float public: - CBotExprNum(); - ~CBotExprNum(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotExprNum(); + ~CBotExprNum(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -1146,68 +1238,68 @@ class CBotExprAlpha : public CBotInstr private: public: - CBotExprAlpha(); - ~CBotExprAlpha(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); + CBotExprAlpha(); + ~CBotExprAlpha(); + static + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; -#define MAX(a,b) ((a>b) ? a : b) +#define MAX(a,b) ((a>b) ? a : b) // classe pour la gestion des nombres entier (int) class CBotVarInt : public CBotVar { private: - int m_val; // la valeur - CBotString m_defnum; // le nom si donné par DefineNum - friend class CBotVar; + int m_val; // la valeur + CBotString m_defnum; // le nom si donné par DefineNum + friend class CBotVar; public: - CBotVarInt( const CBotToken* name ); -// ~CBotVarInt(); + CBotVarInt( const CBotToken* name ); +// ~CBotVarInt(); - void SetValInt(int val, const char* s = NULL); - void SetValFloat(float val); - int GivValInt(); - float GivValFloat(); - CBotString GivValString(); + void SetValInt(int val, const char* s = NULL); + void SetValFloat(float val); + int GivValInt(); + float GivValFloat(); + CBotString GivValString(); - void Copy(CBotVar* pSrc, bool bName=true); + void Copy(CBotVar* pSrc, bool bName=true); - void Add(CBotVar* left, CBotVar* right); // addition - void Sub(CBotVar* left, CBotVar* right); // soustraction - void Mul(CBotVar* left, CBotVar* right); // multiplication - int Div(CBotVar* left, CBotVar* right); // division - int Modulo(CBotVar* left, CBotVar* right); // reste de division - void Power(CBotVar* left, CBotVar* right); // puissance + void Add(CBotVar* left, CBotVar* right); // addition + void Sub(CBotVar* left, CBotVar* right); // soustraction + void Mul(CBotVar* left, CBotVar* right); // multiplication + int Div(CBotVar* left, CBotVar* right); // division + int Modulo(CBotVar* left, CBotVar* right); // reste de division + void Power(CBotVar* left, CBotVar* right); // puissance - bool Lo(CBotVar* left, CBotVar* right); - bool Hi(CBotVar* left, CBotVar* right); - bool Ls(CBotVar* left, CBotVar* right); - bool Hs(CBotVar* left, CBotVar* right); - bool Eq(CBotVar* left, CBotVar* right); - bool Ne(CBotVar* left, CBotVar* right); + bool Lo(CBotVar* left, CBotVar* right); + bool Hi(CBotVar* left, CBotVar* right); + bool Ls(CBotVar* left, CBotVar* right); + bool Hs(CBotVar* left, CBotVar* right); + bool Eq(CBotVar* left, CBotVar* right); + bool Ne(CBotVar* left, CBotVar* right); - void XOr(CBotVar* left, CBotVar* right); - void Or(CBotVar* left, CBotVar* right); - void And(CBotVar* left, CBotVar* right); + void XOr(CBotVar* left, CBotVar* right); + void Or(CBotVar* left, CBotVar* right); + void And(CBotVar* left, CBotVar* right); - void SL(CBotVar* left, CBotVar* right); - void SR(CBotVar* left, CBotVar* right); - void ASR(CBotVar* left, CBotVar* right); + void SL(CBotVar* left, CBotVar* right); + void SR(CBotVar* left, CBotVar* right); + void ASR(CBotVar* left, CBotVar* right); - void Neg(); - void Not(); - void Inc(); - void Dec(); + void Neg(); + void Not(); + void Inc(); + void Dec(); - bool Save0State(FILE* pf); - bool Save1State(FILE* pf); + bool Save0State(FILE* pf); + bool Save1State(FILE* pf); }; @@ -1215,40 +1307,40 @@ public: class CBotVarFloat : public CBotVar { private: - float m_val; // la valeur + float m_val; // la valeur public: - CBotVarFloat( const CBotToken* name ); -// ~CBotVarFloat(); + CBotVarFloat( const CBotToken* name ); +// ~CBotVarFloat(); - void SetValInt(int val, const char* s = NULL); - void SetValFloat(float val); - int GivValInt(); - float GivValFloat(); - CBotString GivValString(); + void SetValInt(int val, const char* s = NULL); + void SetValFloat(float val); + int GivValInt(); + float GivValFloat(); + CBotString GivValString(); - void Copy(CBotVar* pSrc, bool bName=true); + void Copy(CBotVar* pSrc, bool bName=true); - void Add(CBotVar* left, CBotVar* right); // addition - void Sub(CBotVar* left, CBotVar* right); // soustraction - void Mul(CBotVar* left, CBotVar* right); // multiplication - int Div(CBotVar* left, CBotVar* right); // division - int Modulo(CBotVar* left, CBotVar* right); // reste de division - void Power(CBotVar* left, CBotVar* right); // puissance + void Add(CBotVar* left, CBotVar* right); // addition + void Sub(CBotVar* left, CBotVar* right); // soustraction + void Mul(CBotVar* left, CBotVar* right); // multiplication + int Div(CBotVar* left, CBotVar* right); // division + int Modulo(CBotVar* left, CBotVar* right); // reste de division + void Power(CBotVar* left, CBotVar* right); // puissance - bool Lo(CBotVar* left, CBotVar* right); - bool Hi(CBotVar* left, CBotVar* right); - bool Ls(CBotVar* left, CBotVar* right); - bool Hs(CBotVar* left, CBotVar* right); - bool Eq(CBotVar* left, CBotVar* right); - bool Ne(CBotVar* left, CBotVar* right); + bool Lo(CBotVar* left, CBotVar* right); + bool Hi(CBotVar* left, CBotVar* right); + bool Ls(CBotVar* left, CBotVar* right); + bool Hs(CBotVar* left, CBotVar* right); + bool Eq(CBotVar* left, CBotVar* right); + bool Ne(CBotVar* left, CBotVar* right); - void Neg(); - void Inc(); - void Dec(); + void Neg(); + void Inc(); + void Dec(); - bool Save1State(FILE* pf); + bool Save1State(FILE* pf); }; @@ -1256,55 +1348,55 @@ public: class CBotVarString : public CBotVar { private: - CBotString m_val; // la valeur + CBotString m_val; // la valeur public: - CBotVarString( const CBotToken* name ); -// ~CBotVarString(); + CBotVarString( const CBotToken* name ); +// ~CBotVarString(); - void SetValString(const char* p); - CBotString GivValString(); + void SetValString(const char* p); + CBotString GivValString(); - void Copy(CBotVar* pSrc, bool bName=true); + void Copy(CBotVar* pSrc, bool bName=true); - void Add(CBotVar* left, CBotVar* right); // addition + void Add(CBotVar* left, CBotVar* right); // addition - bool Lo(CBotVar* left, CBotVar* right); - bool Hi(CBotVar* left, CBotVar* right); - bool Ls(CBotVar* left, CBotVar* right); - bool Hs(CBotVar* left, CBotVar* right); - bool Eq(CBotVar* left, CBotVar* right); - bool Ne(CBotVar* left, CBotVar* right); + bool Lo(CBotVar* left, CBotVar* right); + bool Hi(CBotVar* left, CBotVar* right); + bool Ls(CBotVar* left, CBotVar* right); + bool Hs(CBotVar* left, CBotVar* right); + bool Eq(CBotVar* left, CBotVar* right); + bool Ne(CBotVar* left, CBotVar* right); - bool Save1State(FILE* pf); + bool Save1State(FILE* pf); }; // classe pour la gestion des boolean class CBotVarBoolean : public CBotVar { private: - bool m_val; // la valeur + bool m_val; // la valeur public: - CBotVarBoolean( const CBotToken* name ); -// ~CBotVarBoolean(); + CBotVarBoolean( const CBotToken* name ); +// ~CBotVarBoolean(); - void SetValInt(int val, const char* s = NULL); - void SetValFloat(float val); - int GivValInt(); - float GivValFloat(); - CBotString GivValString(); + void SetValInt(int val, const char* s = NULL); + void SetValFloat(float val); + int GivValInt(); + float GivValFloat(); + CBotString GivValString(); - void Copy(CBotVar* pSrc, bool bName=true); + void Copy(CBotVar* pSrc, bool bName=true); - void And(CBotVar* left, CBotVar* right); - void Or(CBotVar* left, CBotVar* right); - void XOr(CBotVar* left, CBotVar* right); - void Not(); - bool Eq(CBotVar* left, CBotVar* right); - bool Ne(CBotVar* left, CBotVar* right); + void And(CBotVar* left, CBotVar* right); + void Or(CBotVar* left, CBotVar* right); + void XOr(CBotVar* left, CBotVar* right); + void Not(); + bool Eq(CBotVar* left, CBotVar* right); + bool Ne(CBotVar* left, CBotVar* right); - bool Save1State(FILE* pf); + bool Save1State(FILE* pf); }; @@ -1312,59 +1404,59 @@ public: class CBotVarClass : public CBotVar { private: - static - CBotVarClass* m_ExClass; // liste des instances existantes à un moment donné - CBotVarClass* m_ExNext; // pour cette liste générale - CBotVarClass* m_ExPrev; // pour cette liste générale + static + CBotVarClass* m_ExClass; // liste des instances existantes à un moment donné + CBotVarClass* m_ExNext; // pour cette liste générale + CBotVarClass* m_ExPrev; // pour cette liste générale private: - CBotClass* m_pClass; // la définition de la classe - CBotVarClass* m_pParent; // l'instance dans la classe parent - CBotVar* m_pVar; // contenu - friend class CBotVar; // mon papa est un copain - friend class CBotVarPointer; // et le pointeur aussi - int m_CptUse; // compteur d'utilisation - long m_ItemIdent; // identificateur (unique) de l'instance - bool m_bConstructor; // set si un constructeur a été appelé + CBotClass* m_pClass; // la définition de la classe + CBotVarClass* m_pParent; // l'instance dans la classe parent + CBotVar* m_pVar; // contenu + friend class CBotVar; // mon papa est un copain + friend class CBotVarPointer; // et le pointeur aussi + int m_CptUse; // compteur d'utilisation + long m_ItemIdent; // identificateur (unique) de l'instance + bool m_bConstructor; // set si un constructeur a été appelé public: - CBotVarClass( const CBotToken* name, const CBotTypResult& type ); -// CBotVarClass( const CBotToken* name, CBotTypResult& type, int &nIdent ); - ~CBotVarClass(); -// void InitCBotVarClass( const CBotToken* name, CBotTypResult& type, int &nIdent ); + CBotVarClass( const CBotToken* name, const CBotTypResult& type ); +// CBotVarClass( const CBotToken* name, CBotTypResult& type, int &nIdent ); + ~CBotVarClass(); +// void InitCBotVarClass( const CBotToken* name, CBotTypResult& type, int &nIdent ); - void Copy(CBotVar* pSrc, bool bName=true); - void SetClass(CBotClass* pClass); //, int &nIdent); - CBotClass* GivClass(); - CBotVar* GivItem(const char* name); // rend un élément d'une classe selon son nom (*) - CBotVar* GivItemRef(int nIdent); + void Copy(CBotVar* pSrc, bool bName=true); + void SetClass(CBotClass* pClass); //, int &nIdent); + CBotClass* GivClass(); + CBotVar* GivItem(const char* name); // rend un élément d'une classe selon son nom (*) + CBotVar* GivItemRef(int nIdent); - CBotVar* GivItem(int n, bool bExtend); - CBotVar* GivItemList(); + CBotVar* GivItem(int n, bool bExtend); + CBotVar* GivItemList(); - CBotString GivValString(); + CBotString GivValString(); - bool Save1State(FILE* pf); - void Maj(void* pUser, bool bContinue); + bool Save1State(FILE* pf); + void Maj(void* pUser, bool bContinue); - void IncrementUse(); // une référence en plus - void DecrementUse(); // une référence en moins + void IncrementUse(); // une référence en plus + void DecrementUse(); // une référence en moins - CBotVarClass* - GivPointer(); - void SetItemList(CBotVar* pVar); + CBotVarClass* + GivPointer(); + void SetItemList(CBotVar* pVar); - void SetIdent(long n); - - static CBotVarClass* Find(long id); + void SetIdent(long n); + + static CBotVarClass* Find(long id); -// CBotVar* GivMyThis(); +// CBotVar* GivMyThis(); - bool Eq(CBotVar* left, CBotVar* right); - bool Ne(CBotVar* left, CBotVar* right); + bool Eq(CBotVar* left, CBotVar* right); + bool Ne(CBotVar* left, CBotVar* right); - void ConstructorSet(); + void ConstructorSet(); }; @@ -1372,68 +1464,68 @@ public: class CBotVarPointer : public CBotVar { private: - CBotVarClass* - m_pVarClass; // contenu - CBotClass* m_pClass; // la classe prévue pour ce pointeur - friend class CBotVar; // mon papa est un copain + CBotVarClass* + m_pVarClass; // contenu + CBotClass* m_pClass; // la classe prévue pour ce pointeur + friend class CBotVar; // mon papa est un copain public: - CBotVarPointer( const CBotToken* name, CBotTypResult& type ); - ~CBotVarPointer(); - - void Copy(CBotVar* pSrc, bool bName=true); - void SetClass(CBotClass* pClass); - CBotClass* GivClass(); - CBotVar* GivItem(const char* name); // rend un élément d'une classe selon son nom (*) - CBotVar* GivItemRef(int nIdent); - CBotVar* GivItemList(); - - CBotString GivValString(); - void SetPointer(CBotVar* p); - CBotVarClass* - GivPointer(); - - void SetIdent(long n); // associe un numéro d'identification (unique) - long GivIdent(); // donne le numéro d'identification associé - void ConstructorSet(); - - bool Save1State(FILE* pf); - void Maj(void* pUser, bool bContinue); - - bool Eq(CBotVar* left, CBotVar* right); - bool Ne(CBotVar* left, CBotVar* right); + CBotVarPointer( const CBotToken* name, CBotTypResult& type ); + ~CBotVarPointer(); + + void Copy(CBotVar* pSrc, bool bName=true); + void SetClass(CBotClass* pClass); + CBotClass* GivClass(); + CBotVar* GivItem(const char* name); // rend un élément d'une classe selon son nom (*) + CBotVar* GivItemRef(int nIdent); + CBotVar* GivItemList(); + + CBotString GivValString(); + void SetPointer(CBotVar* p); + CBotVarClass* + GivPointer(); + + void SetIdent(long n); // associe un numéro d'identification (unique) + long GivIdent(); // donne le numéro d'identification associé + void ConstructorSet(); + + bool Save1State(FILE* pf); + void Maj(void* pUser, bool bContinue); + + bool Eq(CBotVar* left, CBotVar* right); + bool Ne(CBotVar* left, CBotVar* right); }; // classe pour les tableaux -#define MAXARRAYSIZE 9999 +#define MAXARRAYSIZE 9999 class CBotVarArray : public CBotVar { private: - CBotVarClass* - m_pInstance; // instance gérant le tableau + CBotVarClass* + m_pInstance; // instance gérant le tableau - friend class CBotVar; // papa est un copain + friend class CBotVar; // papa est un copain public: - CBotVarArray( const CBotToken* name, CBotTypResult& type ); - ~CBotVarArray(); - - void SetPointer(CBotVar* p); - CBotVarClass* - GivPointer(); - - void Copy(CBotVar* pSrc, bool bName=true); - CBotVar* GivItem(int n, bool bGrow=false); // rend un élément selon son index numérique - // agrandi le tableau si nécessaire si bExtend -// CBotVar* GivItem(const char* name); // rend un élément selon son index litéral - CBotVar* GivItemList(); // donne le premier élément de la liste - - CBotString GivValString(); // donne le contenu du tableau dans une chaîne - - bool Save1State(FILE* pf); + CBotVarArray( const CBotToken* name, CBotTypResult& type ); + ~CBotVarArray(); + + void SetPointer(CBotVar* p); + CBotVarClass* + GivPointer(); + + void Copy(CBotVar* pSrc, bool bName=true); + CBotVar* GivItem(int n, bool bGrow=false); // rend un élément selon son index numérique + // agrandi le tableau si nécessaire si bExtend +// CBotVar* GivItem(const char* name); // rend un élément selon son index litéral + CBotVar* GivItemList(); // donne le premier élément de la liste + + CBotString GivValString(); // donne le contenu du tableau dans une chaîne + + bool Save1State(FILE* pf); }; @@ -1455,7 +1547,7 @@ extern bool ReadType(FILE* pf, CBotTypResult& type); extern float GivNumFloat( const char* p ); -#if false +#if false extern void DEBUG( const char* text, int val, CBotStack* pile ); #endif @@ -1465,51 +1557,51 @@ extern void DEBUG( const char* text, int val, CBotStack* pile ); class CBotCall { private: - static - CBotCall* m_ListCalls; - static - void* m_pUser; - long m_nFuncIdent; + static + CBotCall* m_ListCalls; + static + void* m_pUser; + long m_nFuncIdent; private: - CBotString m_name; - bool (*m_rExec) (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser) ; - CBotTypResult - (*m_rComp) (CBotVar* &pVar, void* pUser) ; - CBotCall* m_next; + CBotString m_name; + bool (*m_rExec) (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser) ; + CBotTypResult + (*m_rComp) (CBotVar* &pVar, void* pUser) ; + CBotCall* m_next; public: - CBotCall(const char* name, - bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), - CBotTypResult rCompile (CBotVar* &pVar, void* pUser)); - ~CBotCall(); - - static - bool AddFunction(const char* name, - bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), - CBotTypResult rCompile (CBotVar* &pVar, void* pUser)); - - static - CBotTypResult - CompileCall(CBotToken* &p, CBotVar** ppVars, CBotCStack* pStack, long& nIdent); - static - bool CheckCall(const char* name); - -// static -// int DoCall(CBotToken* &p, CBotVar** ppVars, CBotStack* pStack, CBotTypResult& rettype); - static - int DoCall(long& nIdent, CBotToken* token, CBotVar** ppVars, CBotStack* pStack, CBotTypResult& rettype); -#if STACKRUN - bool Run(CBotStack* pStack); - static - bool RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotStack* pStack); + CBotCall(const char* name, + bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), + CBotTypResult rCompile (CBotVar* &pVar, void* pUser)); + ~CBotCall(); + + static + bool AddFunction(const char* name, + bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), + CBotTypResult rCompile (CBotVar* &pVar, void* pUser)); + + static + CBotTypResult + CompileCall(CBotToken* &p, CBotVar** ppVars, CBotCStack* pStack, long& nIdent); + static + bool CheckCall(const char* name); + +// static +// int DoCall(CBotToken* &p, CBotVar** ppVars, CBotStack* pStack, CBotTypResult& rettype); + static + int DoCall(long& nIdent, CBotToken* token, CBotVar** ppVars, CBotStack* pStack, CBotTypResult& rettype); +#if STACKRUN + bool Run(CBotStack* pStack); + static + bool RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotStack* pStack); #endif - CBotString GivName(); - CBotCall* Next(); - - static void SetPUser(void* pUser); - static void Free(); + CBotString GivName(); + CBotCall* Next(); + + static void SetPUser(void* pUser); + static void Free(); }; // classe gérant les méthodes déclarées par AddFunction sur une classe @@ -1517,31 +1609,31 @@ public: class CBotCallMethode { private: - CBotString m_name; - bool (*m_rExec) (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception); - CBotTypResult - (*m_rComp) (CBotVar* pThis, CBotVar* &pVar); - CBotCallMethode* m_next; - friend class CBotClass; - long m_nFuncIdent; + CBotString m_name; + bool (*m_rExec) (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception); + CBotTypResult + (*m_rComp) (CBotVar* pThis, CBotVar* &pVar); + CBotCallMethode* m_next; + friend class CBotClass; + long m_nFuncIdent; public: - CBotCallMethode(const char* name, - bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), - CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar)); - ~CBotCallMethode(); - - CBotTypResult - CompileCall(const char* name, CBotVar* pThis, - CBotVar** ppVars, CBotCStack* pStack, - long& nIdent); - - int DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotVar* &pResult, CBotStack* pStack, CBotToken* pFunc); - - CBotString GivName(); - CBotCallMethode* Next(); - void AddNext(CBotCallMethode* p); - + CBotCallMethode(const char* name, + bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), + CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar)); + ~CBotCallMethode(); + + CBotTypResult + CompileCall(const char* name, CBotVar* pThis, + CBotVar** ppVars, CBotCStack* pStack, + long& nIdent); + + int DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotVar* &pResult, CBotStack* pStack, CBotToken* pFunc); + + CBotString GivName(); + CBotCallMethode* Next(); + void AddNext(CBotCallMethode* p); + }; // une liste de paramètres @@ -1549,26 +1641,26 @@ public: class CBotDefParam { private: - CBotToken m_token; // nom du paramètre - CBotString m_typename; // nom du type - CBotTypResult m_type; // type de paramètre - CBotDefParam* m_next; // paramètre suivant - long m_nIdent; + CBotToken m_token; // nom du paramètre + CBotString m_typename; // nom du type + CBotTypResult m_type; // type de paramètre + CBotDefParam* m_next; // paramètre suivant + long m_nIdent; public: - CBotDefParam(); - ~CBotDefParam(); - static - CBotDefParam* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotVar** ppVars, CBotStack* &pj); - void RestoreState(CBotStack* &pj, bool bMain); - - void AddNext(CBotDefParam* p); - int GivType(); - CBotTypResult GivTypResult(); - CBotDefParam* GivNext(); - - CBotString GivParamString(); + CBotDefParam(); + ~CBotDefParam(); + static + CBotDefParam* Compile(CBotToken* &p, CBotCStack* pStack); + bool Execute(CBotVar** ppVars, CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); + + void AddNext(CBotDefParam* p); + int GivType(); + CBotTypResult GivTypResult(); + CBotDefParam* GivNext(); + + CBotString GivParamString(); }; @@ -1577,65 +1669,65 @@ public: class CBotFunction : CBotInstr { private: - // gestion d'une liste (static) de fonctions publiques - static - CBotFunction* m_listPublic; - CBotFunction* m_nextpublic; - CBotFunction* m_prevpublic; - friend class CBotCStack; -// long m_nThisIdent; - long m_nFuncIdent; - bool m_bSynchro; // méthode synchronisée ? + // gestion d'une liste (static) de fonctions publiques + static + CBotFunction* m_listPublic; + CBotFunction* m_nextpublic; + CBotFunction* m_prevpublic; + friend class CBotCStack; +// long m_nThisIdent; + long m_nFuncIdent; + bool m_bSynchro; // méthode synchronisée ? private: - CBotDefParam* m_Param; // liste des paramètres - CBotInstr* m_Block; // le bloc d'instructions - CBotFunction* m_next; - CBotToken m_retToken; // si retourne un CBotTypClass - CBotTypResult m_retTyp; // type complet du résultat - - bool m_bPublic; // fonction publique - bool m_bExtern; // fonction extern - CBotString m_MasterClass; // nom de la classe qu'on dérive - CBotProgram* m_pProg; - friend class CBotProgram; - friend class CBotClass; - - CBotToken m_extern; // pour la position du mot "extern" - CBotToken m_openpar; - CBotToken m_closepar; - CBotToken m_openblk; - CBotToken m_closeblk; + CBotDefParam* m_Param; // liste des paramètres + CBotInstr* m_Block; // le bloc d'instructions + CBotFunction* m_next; + CBotToken m_retToken; // si retourne un CBotTypClass + CBotTypResult m_retTyp; // type complet du résultat + + bool m_bPublic; // fonction publique + bool m_bExtern; // fonction extern + CBotString m_MasterClass; // nom de la classe qu'on dérive + CBotProgram* m_pProg; + friend class CBotProgram; + friend class CBotClass; + + CBotToken m_extern; // pour la position du mot "extern" + CBotToken m_openpar; + CBotToken m_closepar; + CBotToken m_openblk; + CBotToken m_closeblk; public: - CBotFunction(); - ~CBotFunction(); - static - CBotFunction* Compile(CBotToken* &p, CBotCStack* pStack, CBotFunction* pFunc, bool bLocal = true); - static - CBotFunction* Compile1(CBotToken* &p, CBotCStack* pStack, CBotClass* pClass); - bool Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance = NULL); - void RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance = NULL); - - void AddNext(CBotFunction* p); - CBotTypResult CompileCall(const char* name, CBotVar** ppVars, long& nIdent); - CBotFunction* FindLocalOrPublic(long& nIdent, const char* name, CBotVar** ppVars, CBotTypResult& TypeOrError, bool bPublic = true); - - int DoCall(long& nIdent, const char* name, CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken); - void RestoreCall(long& nIdent, const char* name, CBotVar** ppVars, CBotStack* pStack); - int DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken, CBotClass* pClass); - void RestoreCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotStack* pStack, CBotClass* pClass); - bool CheckParam(CBotDefParam* pParam); - - static - void AddPublic(CBotFunction* pfunc); - - CBotString GivName(); - CBotString GivParams(); - bool IsPublic(); - bool IsExtern(); - CBotFunction* Next(); - - bool GetPosition(int& start, int& stop, CBotGet modestart, CBotGet modestop); + CBotFunction(); + ~CBotFunction(); + static + CBotFunction* Compile(CBotToken* &p, CBotCStack* pStack, CBotFunction* pFunc, bool bLocal = true); + static + CBotFunction* Compile1(CBotToken* &p, CBotCStack* pStack, CBotClass* pClass); + bool Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance = NULL); + void RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance = NULL); + + void AddNext(CBotFunction* p); + CBotTypResult CompileCall(const char* name, CBotVar** ppVars, long& nIdent); + CBotFunction* FindLocalOrPublic(long& nIdent, const char* name, CBotVar** ppVars, CBotTypResult& TypeOrError, bool bPublic = true); + + int DoCall(long& nIdent, const char* name, CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken); + void RestoreCall(long& nIdent, const char* name, CBotVar** ppVars, CBotStack* pStack); + int DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken, CBotClass* pClass); + void RestoreCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotStack* pStack, CBotClass* pClass); + bool CheckParam(CBotDefParam* pParam); + + static + void AddPublic(CBotFunction* pfunc); + + CBotString GivName(); + CBotString GivParams(); + bool IsPublic(); + bool IsExtern(); + CBotFunction* Next(); + + bool GetPosition(int& start, int& stop, CBotGet modestart, CBotGet modestop); }; diff --git a/src/CBot/CBotDll.h b/src/CBot/CBotDll.h index 514146f..f2e2297 100644 --- a/src/CBot/CBotDll.h +++ b/src/CBot/CBotDll.h @@ -49,20 +49,17 @@ class CBotCStack; // stack // Variables management //////////////////////////////////////////////////////////////////////// -// ces types sont calqués sur les types Java -// ne pas changer l'ordre de ces types - /** \brief CBotType Defines known types. This types are modeled on Java types. Do not change the order of elements */ enum CBotType { CBotTypVoid = 0, - CBotTypByte = 1, - CBotTypShort = 2, - CBotTypChar = 3, + CBotTypByte = 1, //n + CBotTypShort = 2, //n + CBotTypChar = 3, //n CBotTypInt = 4, - CBotTypLong = 5, + CBotTypLong = 5, //n CBotTypFloat = 6, - CBotTypDouble = 7, + CBotTypDouble = 7, //n CBotTypBoolean = 8, CBotTypString = 9, @@ -74,71 +71,79 @@ enum CBotType CBotTypClass = 15, CBotTypIntrinsic = 16 // instance of a class intrinsic }; -//n = non encore implémenté +//n = not implemented yet -// pour SetUserPtr lors de la suppression d'un objet +// for SetUserPtr when deleting an object #define OBJECTDELETED ((void*)-1) -// valeur mise avant initialisation +// value set before initialization #define OBJECTCREATED ((void*)-2) -// classe permettant de définir le type complet d'un résultat +/** \brief CBotTypResult class to define the complete type of a result*/ class CBotTypResult { -private: - int m_type; - CBotTypResult* m_pNext; // pour les types de types - CBotClass* m_pClass; // pour les dérivés de classe - int m_limite; // limitation des tableaux - friend class CBotVarClass; - friend class CBotVarPointer; - public: - // divers constructeurs selon les besoins - CBotTypResult(int type); - // pour les types simples (CBotTypInt à CBotTypString) - CBotTypResult(int type, const char* name); - // pour les types pointeur et classe intrinsic - CBotTypResult(int type, CBotClass* pClass); - // idem à partir de l'instance d'une classe - CBotTypResult(int type, CBotTypResult elem); - // pour les tableaux de variables - - CBotTypResult(const CBotTypResult& typ); - // pour les assignations - CBotTypResult(); - // pour par défaut - ~CBotTypResult(); + /** + * \brief CBotTypResult constructor of an object + * \param type type of created result, see CBotType + */ + CBotTypResult(int type); + + /** + * \brief CBotTypResult constructor for simple types (CBotTypInt to CBotTypString) + * \param type type of created result, see CBotType + * \param name + */ + // pour les types simples (CBotTypInt à CBotTypString) + CBotTypResult(int type, const char* name); + // pour les types pointeur et classe intrinsic + CBotTypResult(int type, CBotClass* pClass); + // idem à partir de l'instance d'une classe + CBotTypResult(int type, CBotTypResult elem); + // pour les tableaux de variables + + CBotTypResult(const CBotTypResult& typ); + // pour les assignations + CBotTypResult(); + // pour par défaut + ~CBotTypResult(); int GivType(int mode = 0) const; - // rend le type CBotTyp* du résultat + // rend le type CBotTyp* du résultat void SetType(int n); - // modifie le type + // modifie le type CBotClass* GivClass() const; - // rend le pointeur à la classe (pour les CBotTypClass, CBotTypPointer) + // rend le pointeur à la classe (pour les CBotTypClass, CBotTypPointer) int GivLimite() const; - // rend la taille limite du tableau (CBotTypArray) + // rend la taille limite du tableau (CBotTypArray) void SetLimite(int n); - // fixe une limite au tableau + // fixe une limite au tableau void SetArray(int* max ); - // idem avec une liste de dimension (tableaux de tableaux) + // idem avec une liste de dimension (tableaux de tableaux) CBotTypResult& GivTypElem() const; - // rend le type des éléments du tableau (CBotTypArray) + // rend le type des éléments du tableau (CBotTypArray) bool Compare(const CBotTypResult& typ) const; - // compare si les types sont compatibles + // compare si les types sont compatibles bool Eq(int type) const; - // compare le type + // compare le type CBotTypResult& - operator=(const CBotTypResult& src); - // copie un type complet dans un autre + operator=(const CBotTypResult& src); + // copie un type complet dans un autre +private: + int m_type; + CBotTypResult* m_pNext; // pour les types de types + CBotClass* m_pClass; // pour les dérivés de classe + int m_limite; // limitation des tableaux + friend class CBotVarClass; + friend class CBotVarPointer; }; /* @@ -236,11 +241,12 @@ public: //////////////////////////////////////////////////////////////////////// -// définie une classe pour l'utilisation des strings +// // car CString fait partie de MFC pas utilisé ici. // // ( toutes les fonctions ne sont pas encore implémentées ) +/** \brief CBotString Class used to work on strings */ class CBotString { public: @@ -303,7 +309,7 @@ private: int m_lg; /** \brief Keeps the string corresponding to keyword ID */ - static const std::map s_keywordString; + static const std::map s_keywordString; /** * \brief MapIdToString maps given ID to its string equivalent diff --git a/src/CBot/CBotFunction.cpp b/src/CBot/CBotFunction.cpp index 784e647..363b939 100644 --- a/src/CBot/CBotFunction.cpp +++ b/src/CBot/CBotFunction.cpp @@ -1379,7 +1379,6 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack) if (IsOfType(p, TokenTypVar)) { CBotClass* pPapa = NULL; -#if EXTENDS if ( IsOfType( p, ID_EXTENDS ) ) { CBotString name = p->GivString(); @@ -1391,7 +1390,6 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack) return NULL; } } -#endif CBotClass* classe = (pOld == NULL) ? new CBotClass(name, pPapa) : pOld; classe->Purge(); // vide les anciennes définitions classe->m_IsDef = false; // définition en cours @@ -1627,12 +1625,10 @@ CBotClass* CBotClass::Compile(CBotToken* &p, CBotCStack* pStack) // la classe à été créée par Compile1 CBotClass* pOld = CBotClass::Find(name); -#if EXTENDS if ( IsOfType( p, ID_EXTENDS ) ) { IsOfType(p, TokenTypVar); // forcément } -#endif IsOfType( p, ID_OPBLK); // forcément while ( pStack->IsOk() && !IsOfType( p, ID_CLBLK ) ) diff --git a/src/CBot/CBotStack.cpp b/src/CBot/CBotStack.cpp index 291a1e5..419798f 100644 --- a/src/CBot/CBotStack.cpp +++ b/src/CBot/CBotStack.cpp @@ -14,10 +14,7 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/.////////////////////////////////////////////////////////////////////// -/** - * \file CBotStack.cpp - * \brief Management of the stack - */ +//Management of the stack #include "CBot.h" @@ -25,7 +22,7 @@ #include -#define ITIMER 100 +#define ITIMER 100 //////////////////////////////////////////////////////////////////////////// // gestion de la pile d'exécution @@ -40,202 +37,202 @@ int CBotStack::m_end = 0; CBotString CBotStack::m_labelBreak=""; void* CBotStack::m_pUser = NULL; -#if STACKMEM +#if STACKMEM CBotStack* CBotStack::FirstStack() { - CBotStack* p; - - long size = sizeof(CBotStack); - size *= (MAXSTACK+10); - - // demande une tranche mémoire pour la pile - p = (CBotStack*)malloc(size); - - // la vide totalement - memset(p, 0, size); - - p-> m_bBlock = true; - m_timer = m_initimer; // met le timer au début - - CBotStack* pp = p; - pp += MAXSTACK; - int i; - for ( i = 0 ; i< 10 ; i++ ) - { - pp->m_bOver = true; - pp ++; - } -#ifdef _DEBUG - int n = 1; - pp = p; - for ( i = 0 ; i< MAXSTACK+10 ; i++ ) - { - pp->m_index = n++; - pp ++; - } + CBotStack* p; + + long size = sizeof(CBotStack); + size *= (MAXSTACK+10); + + // demande une tranche mémoire pour la pile + p = (CBotStack*)malloc(size); + + // la vide totalement + memset(p, 0, size); + + p-> m_bBlock = true; + m_timer = m_initimer; // met le timer au début + + CBotStack* pp = p; + pp += MAXSTACK; + int i; + for ( i = 0 ; i< 10 ; i++ ) + { + pp->m_bOver = true; + pp ++; + } +#ifdef _DEBUG + int n = 1; + pp = p; + for ( i = 0 ; i< MAXSTACK+10 ; i++ ) + { + pp->m_index = n++; + pp ++; + } #endif - m_error = 0; // évite des blocages car m_error est static - return p; + m_error = 0; // évite des blocages car m_error est static + return p; } CBotStack::CBotStack(CBotStack* ppapa) { - // constructor must exist or the destructor is never called! + // constructor must exist or the destructor is never called! ASM_TRAP(); } CBotStack::~CBotStack() { - ASM_TRAP(); // utiliser Delete() à la place + ASM_TRAP(); // utiliser Delete() à la place } void CBotStack::Delete() { - if ( this == NULL || this == EOX ) return; + if ( this == NULL || this == EOX ) return; - m_next->Delete(); - m_next2->Delete(); + m_next->Delete(); + m_next2->Delete(); - if (m_prev != NULL) - { - if ( m_prev->m_next == this ) - m_prev->m_next = NULL; // enlève de la chaîne + if (m_prev != NULL) + { + if ( m_prev->m_next == this ) + m_prev->m_next = NULL; // enlève de la chaîne - if ( m_prev->m_next2 == this ) - m_prev->m_next2 = NULL; // enlève de la chaîne - } + if ( m_prev->m_next2 == this ) + m_prev->m_next2 = NULL; // enlève de la chaîne + } - delete m_var; - delete m_listVar; + delete m_var; + delete m_listVar; - CBotStack* p = m_prev; - bool bOver = m_bOver; -#ifdef _DEBUG - int n = m_index; + CBotStack* p = m_prev; + bool bOver = m_bOver; +#ifdef _DEBUG + int n = m_index; #endif - // efface le bloc libéré - memset(this, 0, sizeof(CBotStack)); - m_bOver = bOver; -#ifdef _DEBUG - m_index = n; + // efface le bloc libéré + memset(this, 0, sizeof(CBotStack)); + m_bOver = bOver; +#ifdef _DEBUG + m_index = n; #endif - if ( p == NULL ) - free( this ); + if ( p == NULL ) + free( this ); } // routine optimisée CBotStack* CBotStack::AddStack(CBotInstr* instr, bool bBlock) { - if (m_next != NULL) - { - return m_next; // reprise dans une pile existante - } + if (m_next != NULL) + { + return m_next; // reprise dans une pile existante + } -#ifdef _DEBUG - int n = 0; +#ifdef _DEBUG + int n = 0; #endif - CBotStack* p = this; - do - { - p ++; -#ifdef _DEBUG - n ++; + CBotStack* p = this; + do + { + p ++; +#ifdef _DEBUG + n ++; #endif - } - while ( p->m_prev != NULL ); + } + while ( p->m_prev != NULL ); - m_next = p; // chaîne l'élément - p->m_bBlock = bBlock; - p->m_instr = instr; - p->m_prog = m_prog; - p->m_step = 0; - p->m_prev = this; - p->m_state = 0; - p->m_call = NULL; - p->m_bFunc = false; - return p; + m_next = p; // chaîne l'élément + p->m_bBlock = bBlock; + p->m_instr = instr; + p->m_prog = m_prog; + p->m_step = 0; + p->m_prev = this; + p->m_state = 0; + p->m_call = NULL; + p->m_bFunc = false; + return p; } CBotStack* CBotStack::AddStackEOX(CBotCall* instr, bool bBlock) { - if (m_next != NULL) - { - if ( m_next == EOX ) - { - m_next = NULL; - return EOX; - } - return m_next; // reprise dans une pile existante - } - CBotStack* p = AddStack(NULL, bBlock); - p->m_call = instr; - p->m_bFunc = 2; // spécial - return p; + if (m_next != NULL) + { + if ( m_next == EOX ) + { + m_next = NULL; + return EOX; + } + return m_next; // reprise dans une pile existante + } + CBotStack* p = AddStack(NULL, bBlock); + p->m_call = instr; + p->m_bFunc = 2; // spécial + return p; } CBotStack* CBotStack::AddStack2(bool bBlock) { - if (m_next2 != NULL) - { - m_next2->m_prog = m_prog; // spécial évite un RestoreStack2 - return m_next2; // reprise dans une pile existante - } + if (m_next2 != NULL) + { + m_next2->m_prog = m_prog; // spécial évite un RestoreStack2 + return m_next2; // reprise dans une pile existante + } - CBotStack* p = this; - do - { - p ++; - } - while ( p->m_prev != NULL ); + CBotStack* p = this; + do + { + p ++; + } + while ( p->m_prev != NULL ); - m_next2 = p; // chaîne l'élément - p->m_prev = this; - p->m_bBlock = bBlock; - p->m_prog = m_prog; - p->m_step = 0; - return p; + m_next2 = p; // chaîne l'élément + p->m_prev = this; + p->m_bBlock = bBlock; + p->m_prog = m_prog; + p->m_step = 0; + return p; } bool CBotStack::GivBlock() { - return m_bBlock; + return m_bBlock; } bool CBotStack::Return(CBotStack* pfils) { - if ( pfils == this ) return true; // spécial + if ( pfils == this ) return true; // spécial - if (m_var != NULL) delete m_var; // valeur remplacée ? - m_var = pfils->m_var; // résultat transmis - pfils->m_var = NULL; // ne pas détruire la variable + if (m_var != NULL) delete m_var; // valeur remplacée ? + m_var = pfils->m_var; // résultat transmis + pfils->m_var = NULL; // ne pas détruire la variable - m_next->Delete();m_next = NULL; // libère la pile au dessus - m_next2->Delete();m_next2 = NULL; // aussi la seconde pile (catch) + m_next->Delete();m_next = NULL; // libère la pile au dessus + m_next2->Delete();m_next2 = NULL; // aussi la seconde pile (catch) - return (m_error == 0); // interrompu si erreur + return (m_error == 0); // interrompu si erreur } bool CBotStack::ReturnKeep(CBotStack* pfils) { - if ( pfils == this ) return true; // spécial + if ( pfils == this ) return true; // spécial - if (m_var != NULL) delete m_var; // valeur remplacée ? - m_var = pfils->m_var; // résultat transmis - pfils->m_var = NULL; // ne pas détruire la variable + if (m_var != NULL) delete m_var; // valeur remplacée ? + m_var = pfils->m_var; // résultat transmis + pfils->m_var = NULL; // ne pas détruire la variable - return (m_error == 0); // interrompu si erreur + return (m_error == 0); // interrompu si erreur } bool CBotStack::StackOver() { - if (!m_bOver) return false; - m_error = TX_STACKOVER; - return true; + if (!m_bOver) return false; + m_error = TX_STACKOVER; + return true; } #else @@ -246,118 +243,118 @@ CBotStack::CBotStack(CBotStack* ppapa) m_next2 = NULL; m_prev = ppapa; - m_bBlock = (ppapa == NULL) ? true : false; + m_bBlock = (ppapa == NULL) ? true : false; m_state = 0; - m_step = 1; + m_step = 1; - if (ppapa == NULL) m_timer = m_initimer; // met le timer au début + if (ppapa == NULL) m_timer = m_initimer; // met le timer au début - m_listVar = NULL; - m_bDontDelete = false; - - m_var = NULL; - m_prog = NULL; - m_instr = NULL; - m_call = NULL; - m_bFunc = false; + m_listVar = NULL; + m_bDontDelete = false; + + m_var = NULL; + m_prog = NULL; + m_instr = NULL; + m_call = NULL; + m_bFunc = false; } // destructeur CBotStack::~CBotStack() { - if ( m_next != EOX) delete m_next; - delete m_next2; - if (m_prev != NULL && m_prev->m_next == this ) - m_prev->m_next = NULL; // enlève de la chaîne + if ( m_next != EOX) delete m_next; + delete m_next2; + if (m_prev != NULL && m_prev->m_next == this ) + m_prev->m_next = NULL; // enlève de la chaîne - delete m_var; - if ( !m_bDontDelete ) delete m_listVar; + delete m_var; + if ( !m_bDontDelete ) delete m_listVar; } // routine à optimiser CBotStack* CBotStack::AddStack(CBotInstr* instr, bool bBlock) { - if (m_next != NULL) - { - return m_next; // reprise dans une pile existante - } - CBotStack* p = new CBotStack(this); - m_next = p; // chaîne l'élément - p->m_bBlock = bBlock; - p->m_instr = instr; - p->m_prog = m_prog; - p->m_step = 0; - return p; + if (m_next != NULL) + { + return m_next; // reprise dans une pile existante + } + CBotStack* p = new CBotStack(this); + m_next = p; // chaîne l'élément + p->m_bBlock = bBlock; + p->m_instr = instr; + p->m_prog = m_prog; + p->m_step = 0; + return p; } CBotStack* CBotStack::AddStackEOX(CBotCall* instr, bool bBlock) { - if (m_next != NULL) - { - if ( m_next == EOX ) - { - m_next = NULL; - return EOX; - } - return m_next; // reprise dans une pile existante - } - CBotStack* p = new CBotStack(this); - m_next = p; // chaîne l'élément - p->m_bBlock = bBlock; - p->m_call = instr; - p->m_prog = m_prog; - p->m_step = 0; - p->m_bFunc = 2; // spécial - return p; + if (m_next != NULL) + { + if ( m_next == EOX ) + { + m_next = NULL; + return EOX; + } + return m_next; // reprise dans une pile existante + } + CBotStack* p = new CBotStack(this); + m_next = p; // chaîne l'élément + p->m_bBlock = bBlock; + p->m_call = instr; + p->m_prog = m_prog; + p->m_step = 0; + p->m_bFunc = 2; // spécial + return p; } CBotStack* CBotStack::AddStack2(bool bBlock) { - if (m_next2 != NULL) - { - m_next2->m_prog = m_prog; // spécial évite un RestoreStack2 - return m_next2; // reprise dans une pile existante - } + if (m_next2 != NULL) + { + m_next2->m_prog = m_prog; // spécial évite un RestoreStack2 + return m_next2; // reprise dans une pile existante + } - CBotStack* p = new CBotStack(this); - m_next2 = p; // chaîne l'élément - p->m_bBlock = bBlock; - p->m_prog = m_prog; - p->m_step = 0; + CBotStack* p = new CBotStack(this); + m_next2 = p; // chaîne l'élément + p->m_bBlock = bBlock; + p->m_prog = m_prog; + p->m_step = 0; - return p; + return p; } bool CBotStack::Return(CBotStack* pfils) { - if ( pfils == this ) return true; // spécial + if ( pfils == this ) return true; // spécial - if (m_var != NULL) delete m_var; // valeur remplacée ? - m_var = pfils->m_var; // résultat transmis - pfils->m_var = NULL; // ne pas détruite la variable + if (m_var != NULL) delete m_var; // valeur remplacée ? + m_var = pfils->m_var; // résultat transmis + pfils->m_var = NULL; // ne pas détruite la variable - if ( m_next != EOX ) delete m_next; // libère la pile au dessus - delete m_next2;m_next2 = NULL; // aussi la seconde pile (catch) + if ( m_next != EOX ) delete m_next; // libère la pile au dessus + delete m_next2;m_next2 = NULL; // aussi la seconde pile (catch) - return (m_error == 0); // interrompu si erreur + return (m_error == 0); // interrompu si erreur } bool CBotStack::StackOver() { - return false; // pas de test de débordement dans cette version + return false; // pas de test de débordement dans cette version } #endif void CBotStack::Reset(void* pUser) { - m_timer = m_initimer; // remet le timer - m_error = 0; -// m_start = 0; -// m_end = 0; - m_labelBreak.Empty(); - m_pUser = pUser; + m_timer = m_initimer; // remet le timer + m_error = 0; +// m_start = 0; +// m_end = 0; + m_labelBreak.Empty(); + m_pUser = pUser; } @@ -365,20 +362,20 @@ void CBotStack::Reset(void* pUser) CBotStack* CBotStack::RestoreStack(CBotInstr* instr) { - if (m_next != NULL) - { - m_next->m_instr = instr; // réinit (si reprise après restitution) - m_next->m_prog = m_prog; - return m_next; // reprise dans une pile existante - } - return NULL; + if (m_next != NULL) + { + m_next->m_instr = instr; // réinit (si reprise après restitution) + m_next->m_prog = m_prog; + return m_next; // reprise dans une pile existante + } + return NULL; } CBotStack* CBotStack::RestoreStackEOX(CBotCall* instr) { - CBotStack* p = RestoreStack(); - p->m_call = instr; - return p; + CBotStack* p = RestoreStack(); + p->m_call = instr; + return p; } @@ -386,181 +383,173 @@ CBotStack* CBotStack::RestoreStackEOX(CBotCall* instr) // routine pour l'exécution pas à pas bool CBotStack::IfStep() { - if ( m_initimer > 0 || m_step++ > 0 ) return false; - return true; + if ( m_initimer > 0 || m_step++ > 0 ) return false; + return true; } bool CBotStack::BreakReturn(CBotStack* pfils, const char* name) { - if ( m_error>=0 ) return false; // sortie normale - if ( m_error==-3 ) return false; // sortie normale (return en cours) + if ( m_error>=0 ) return false; // sortie normale + if ( m_error==-3 ) return false; // sortie normale (return en cours) - if (!m_labelBreak.IsEmpty() && (name[0] == 0 || m_labelBreak != name)) - return false; // c'est pas pour moi + if (!m_labelBreak.IsEmpty() && (name[0] == 0 || m_labelBreak != name)) + return false; // c'est pas pour moi - m_error = 0; - m_labelBreak.Empty(); - return Return(pfils); + m_error = 0; + m_labelBreak.Empty(); + return Return(pfils); } bool CBotStack::IfContinue(int state, const char* name) { - if ( m_error != -2 ) return false; + if ( m_error != -2 ) return false; - if (!m_labelBreak.IsEmpty() && (name == NULL || m_labelBreak != name)) - return false; // c'est pas pour moi + if (!m_labelBreak.IsEmpty() && (name == NULL || m_labelBreak != name)) + return false; // c'est pas pour moi - m_state = state; // où reprendre ? - m_error = 0; - m_labelBreak.Empty(); - if ( m_next != EOX ) m_next->Delete(); // purge la pile au dessus - return true; + m_state = state; // où reprendre ? + m_error = 0; + m_labelBreak.Empty(); + if ( m_next != EOX ) m_next->Delete(); // purge la pile au dessus + return true; } void CBotStack::SetBreak(int val, const char* name) { - m_error = -val; // réagit comme une Exception - m_labelBreak = name; - if (val == 3) // pour un return - { - m_retvar = m_var; - m_var = NULL; - } + m_error = -val; // réagit comme une Exception + m_labelBreak = name; + if (val == 3) // pour un return + { + m_retvar = m_var; + m_var = NULL; + } } // remet sur la pile la valeur calculée par le dernier CBotReturn bool CBotStack::GivRetVar(bool bRet) { - if (m_error == -3) - { - if ( m_var ) delete m_var; - m_var = m_retvar; - m_retvar = NULL; - m_error = 0; - return true; - } - return bRet; // interrompu par autre chose que return + if (m_error == -3) + { + if ( m_var ) delete m_var; + m_var = m_retvar; + m_retvar = NULL; + m_error = 0; + return true; + } + return bRet; // interrompu par autre chose que return } int CBotStack::GivError(int& start, int& end) { - start = m_start; - end = m_end; - return m_error; + start = m_start; + end = m_end; + return m_error; } -// type d'instruction sur la pile int CBotStack::GivType(int mode) { - if (m_var == NULL) return -1; - return m_var->GivType(mode); + if (m_var == NULL) return -1; + return m_var->GivType(mode); } -// type d'instruction sur la pile CBotTypResult CBotStack::GivTypResult(int mode) { - if (m_var == NULL) return -1; - return m_var->GivTypResult(mode); + if (m_var == NULL) return -1; + return m_var->GivTypResult(mode); } -// type d'instruction sur la pile void CBotStack::SetType(CBotTypResult& type) { - if (m_var == NULL) return; - m_var->SetType( type ); + if (m_var == NULL) return; + m_var->SetType( type ); } -// trouve une variable par son token -// ce peut être une variable composée avec un point CBotVar* CBotStack::FindVar(CBotToken* &pToken, bool bUpdate, bool bModif) { - CBotStack* p = this; - CBotString name = pToken->GivString(); + CBotStack* p = this; + CBotString name = pToken->GivString(); - while (p != NULL) - { - CBotVar* pp = p->m_listVar; - while ( pp != NULL) - { - if (pp->GivName() == name) - { - if ( bUpdate ) - pp->Maj(m_pUser, false); + while (p != NULL) + { + CBotVar* pp = p->m_listVar; + while ( pp != NULL) + { + if (pp->GivName() == name) + { + if ( bUpdate ) + pp->Maj(m_pUser, false); - return pp; - } - pp = pp->m_next; - } - p = p->m_prev; - } - return NULL; + return pp; + } + pp = pp->m_next; + } + p = p->m_prev; + } + return NULL; } CBotVar* CBotStack::FindVar(const char* name) { - CBotStack* p = this; - while (p != NULL) - { - CBotVar* pp = p->m_listVar; - while ( pp != NULL) - { - if (pp->GivName() == name) - { - return pp; - } - pp = pp->m_next; - } - p = p->m_prev; - } - return NULL; -} - -// retrouve une variable sur la pile selon son numéro d'identification -// ce qui va plus vite que de comparer les noms. + CBotStack* p = this; + while (p != NULL) + { + CBotVar* pp = p->m_listVar; + while ( pp != NULL) + { + if (pp->GivName() == name) + { + return pp; + } + pp = pp->m_next; + } + p = p->m_prev; + } + return NULL; +} CBotVar* CBotStack::FindVar(long ident, bool bUpdate, bool bModif) { - CBotStack* p = this; - while (p != NULL) - { - CBotVar* pp = p->m_listVar; - while ( pp != NULL) - { - if (pp->GivUniqNum() == ident) - { - if ( bUpdate ) - pp->Maj(m_pUser, false); + CBotStack* p = this; + while (p != NULL) + { + CBotVar* pp = p->m_listVar; + while ( pp != NULL) + { + if (pp->GivUniqNum() == ident) + { + if ( bUpdate ) + pp->Maj(m_pUser, false); - return pp; - } - pp = pp->m_next; - } - p = p->m_prev; - } - return NULL; + return pp; + } + pp = pp->m_next; + } + p = p->m_prev; + } + return NULL; } CBotVar* CBotStack::FindVar(CBotToken& Token, bool bUpdate, bool bModif) { - CBotToken* pt = &Token; - return FindVar(pt, bUpdate, bModif); + CBotToken* pt = &Token; + return FindVar(pt, bUpdate, bModif); } CBotVar* CBotStack::CopyVar(CBotToken& Token, bool bUpdate) { - CBotVar* pVar = FindVar( Token, bUpdate ); + CBotVar* pVar = FindVar( Token, bUpdate ); - if ( pVar == NULL) return NULL; + if ( pVar == NULL) return NULL; - CBotVar* pCopy = CBotVar::Create(pVar); - pCopy->Copy(pVar); - return pCopy; + CBotVar* pCopy = CBotVar::Create(pVar); + pCopy->Copy(pVar); + return pCopy; } @@ -568,120 +557,120 @@ bool CBotStack::SetState(int n, int limite) { m_state = n; - m_timer--; // décompte les opérations - return ( m_timer > limite ); // interrompu si timer passé + m_timer--; // décompte les opérations + return ( m_timer > limite ); // interrompu si timer passé } bool CBotStack::IncState(int limite) { - m_state++; + m_state++; - m_timer--; // décompte les opérations - return ( m_timer > limite ); // interrompu si timer passé + m_timer--; // décompte les opérations + return ( m_timer > limite ); // interrompu si timer passé } void CBotStack::SetError(int n, CBotToken* token) { - if ( n!= 0 && m_error != 0) return; // ne change pas une erreur déjà existante - m_error = n; - if (token != NULL) - { - m_start = token->GivStart(); - m_end = token->GivEnd(); - } + if ( n!= 0 && m_error != 0) return; // ne change pas une erreur déjà existante + m_error = n; + if (token != NULL) + { + m_start = token->GivStart(); + m_end = token->GivEnd(); + } } void CBotStack::ResetError(int n, int start, int end) { - m_error = n; - m_start = start; - m_end = end; + m_error = n; + m_start = start; + m_end = end; } void CBotStack::SetPosError(CBotToken* token) { - m_start = token->GivStart(); - m_end = token->GivEnd(); + m_start = token->GivStart(); + m_end = token->GivEnd(); } void CBotStack::SetTimer(int n) { - m_initimer = n; + m_initimer = n; } bool CBotStack::Execute() { - CBotCall* instr = NULL; // instruction la plus élevée - CBotStack* pile; + CBotCall* instr = NULL; // instruction la plus élevée + CBotStack* pile; - CBotStack* p = this; + CBotStack* p = this; - while (p != NULL) - { - if ( p->m_next2 != NULL ) break; - if ( p->m_call != NULL ) - { - instr = p->m_call; - pile = p->m_prev ; - } - p = p->m_next; - } + while (p != NULL) + { + if ( p->m_next2 != NULL ) break; + if ( p->m_call != NULL ) + { + instr = p->m_call; + pile = p->m_prev ; + } + p = p->m_next; + } - if ( instr == NULL ) return true; // exécution normale demandée + if ( instr == NULL ) return true; // exécution normale demandée - if (!instr->Run(pile)) return false; // exécution à partir de là + if (!instr->Run(pile)) return false; // exécution à partir de là -#if STACKMEM - pile->m_next->Delete(); +#if STACKMEM + pile->m_next->Delete(); #else - delete pile->m_next; + delete pile->m_next; #endif - pile->m_next = EOX; // spécial pour reprise - return true; + pile->m_next = EOX; // spécial pour reprise + return true; } // met sur le stack le pointeur à une variable void CBotStack::SetVar( CBotVar* var ) { - if (m_var) delete m_var; // remplacement d'une variable - m_var = var; + if (m_var) delete m_var; // remplacement d'une variable + m_var = var; } // met sur le stack une copie d'une variable void CBotStack::SetCopyVar( CBotVar* var ) { - if (m_var) delete m_var; // remplacement d'une variable + if (m_var) delete m_var; // remplacement d'une variable - m_var = CBotVar::Create("", var->GivTypResult(2)); - m_var->Copy( var ); + m_var = CBotVar::Create("", var->GivTypResult(2)); + m_var->Copy( var ); } CBotVar* CBotStack::GivVar() { - return m_var; + return m_var; } CBotVar* CBotStack::GivPtVar() { - CBotVar* p = m_var; - m_var = NULL; // ne sera pas détruit donc - return p; + CBotVar* p = m_var; + m_var = NULL; // ne sera pas détruit donc + return p; } CBotVar* CBotStack::GivCopyVar() { - if (m_var == NULL) return NULL; - CBotVar* v = CBotVar::Create("", m_var->GivType()); - v->Copy( m_var ); - return v; + if (m_var == NULL) return NULL; + CBotVar* v = CBotVar::Create("", m_var->GivType()); + v->Copy( m_var ); + return v; } long CBotStack::GivVal() { - if (m_var == NULL) return 0; - return m_var->GivValInt(); + if (m_var == NULL) return 0; + return m_var->GivValInt(); } @@ -689,431 +678,431 @@ long CBotStack::GivVal() void CBotStack::AddVar(CBotVar* pVar) { - CBotStack* p = this; + CBotStack* p = this; - // revient sur l'élement père - while (p != NULL && p->m_bBlock == 0) p = p->m_prev; + // revient sur l'élement père + while (p != NULL && p->m_bBlock == 0) p = p->m_prev; - if ( p == NULL ) return; - -/// p->m_bDontDelete = bDontDelete; + if ( p == NULL ) return; + +/// p->m_bDontDelete = bDontDelete; - CBotVar** pp = &p->m_listVar; - while ( *pp != NULL ) pp = &(*pp)->m_next; + CBotVar** pp = &p->m_listVar; + while ( *pp != NULL ) pp = &(*pp)->m_next; - *pp = pVar; // ajoute à la suite + *pp = pVar; // ajoute à la suite -#ifdef _DEBUG - if ( pVar->GivUniqNum() == 0 ) ASM_TRAP(); +#ifdef _DEBUG + if ( pVar->GivUniqNum() == 0 ) ASM_TRAP(); #endif } /*void CBotStack::RestoreVar(CBotVar* pVar) { - if ( !m_bDontDelete ) __asm int 3; - delete m_listVar; - m_listVar = pVar; // remplace directement + if ( !m_bDontDelete ) __asm int 3; + delete m_listVar; + m_listVar = pVar; // remplace directement }*/ void CBotStack::SetBotCall(CBotProgram* p) { - m_prog = p; - m_bFunc = true; + m_prog = p; + m_bFunc = true; } CBotProgram* CBotStack::GivBotCall(bool bFirst) { - if ( ! bFirst ) return m_prog; - CBotStack* p = this; - while ( p->m_prev != NULL ) p = p->m_prev; - return p->m_prog; + if ( ! bFirst ) return m_prog; + CBotStack* p = this; + while ( p->m_prev != NULL ) p = p->m_prev; + return p->m_prog; } void* CBotStack::GivPUser() { - return m_pUser; + return m_pUser; } bool CBotStack::ExecuteCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotTypResult& rettype) { - CBotTypResult res; + CBotTypResult res; - // cherche d'abord selon l'identificateur + // cherche d'abord selon l'identificateur - res = CBotCall::DoCall(nIdent, NULL, ppVar, this, rettype ); - if (res.GivType() >= 0) return res.GivType(); + res = CBotCall::DoCall(nIdent, NULL, ppVar, this, rettype ); + if (res.GivType() >= 0) return res.GivType(); - res = m_prog->GivFunctions()->DoCall(nIdent, NULL, ppVar, this, token ); - if (res.GivType() >= 0) return res.GivType(); + res = m_prog->GivFunctions()->DoCall(nIdent, NULL, ppVar, this, token ); + if (res.GivType() >= 0) return res.GivType(); - // si pas trouvé (recompilé ?) cherche selon le nom + // si pas trouvé (recompilé ?) cherche selon le nom - nIdent = 0; - res = CBotCall::DoCall(nIdent, token, ppVar, this, rettype ); - if (res.GivType() >= 0) return res.GivType(); + nIdent = 0; + res = CBotCall::DoCall(nIdent, token, ppVar, this, rettype ); + if (res.GivType() >= 0) return res.GivType(); - res = m_prog->GivFunctions()->DoCall(nIdent, token->GivString(), ppVar, this, token ); - if (res.GivType() >= 0) return res.GivType(); + res = m_prog->GivFunctions()->DoCall(nIdent, token->GivString(), ppVar, this, token ); + if (res.GivType() >= 0) return res.GivType(); - SetError(TX_NOCALL, token); - return true; + SetError(TX_NOCALL, token); + return true; } void CBotStack::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar) { - if ( m_next == NULL ) return; + if ( m_next == NULL ) return; - if ( !CBotCall::RestoreCall(nIdent, token, ppVar, this) ) - m_prog->GivFunctions()->RestoreCall(nIdent, token->GivString(), ppVar, this ); + if ( !CBotCall::RestoreCall(nIdent, token, ppVar, this) ) + m_prog->GivFunctions()->RestoreCall(nIdent, token->GivString(), ppVar, this ); } bool SaveVar(FILE* pf, CBotVar* pVar) { - while ( true ) - { - if ( pVar == NULL ) - { - return WriteWord(pf, 0); // met un terminateur - } + while ( true ) + { + if ( pVar == NULL ) + { + return WriteWord(pf, 0); // met un terminateur + } - if ( !pVar->Save0State(pf)) return false; // entête commune - if ( !pVar->Save1State(pf) ) return false; // sauve selon la classe fille + if ( !pVar->Save0State(pf)) return false; // entête commune + if ( !pVar->Save1State(pf) ) return false; // sauve selon la classe fille - pVar = pVar->GivNext(); - } + pVar = pVar->GivNext(); + } } void CBotStack::GetRunPos(const char* &FunctionName, int &start, int &end) { - CBotProgram* prog = m_prog; // programme courrant + CBotProgram* prog = m_prog; // programme courrant - CBotInstr* funct = NULL; // fonction trouvée - CBotInstr* instr = NULL; // instruction la plus élevée + CBotInstr* funct = NULL; // fonction trouvée + CBotInstr* instr = NULL; // instruction la plus élevée - CBotStack* p = this; + CBotStack* p = this; - while (p->m_next != NULL) - { - if ( p->m_instr != NULL ) instr = p->m_instr; - if ( p->m_bFunc == 1 ) funct = p->m_instr; - if ( p->m_next->m_prog != prog ) break ; + while (p->m_next != NULL) + { + if ( p->m_instr != NULL ) instr = p->m_instr; + if ( p->m_bFunc == 1 ) funct = p->m_instr; + if ( p->m_next->m_prog != prog ) break ; - if (p->m_next2 && p->m_next2->m_state != 0) p = p->m_next2 ; - else p = p->m_next; - } + if (p->m_next2 && p->m_next2->m_state != 0) p = p->m_next2 ; + else p = p->m_next; + } - if ( p->m_instr != NULL ) instr = p->m_instr; - if ( p->m_bFunc == 1 ) funct = p->m_instr; + if ( p->m_instr != NULL ) instr = p->m_instr; + if ( p->m_bFunc == 1 ) funct = p->m_instr; - if ( funct == NULL ) return; + if ( funct == NULL ) return; - CBotToken* t = funct->GivToken(); - FunctionName = t->GivString(); + CBotToken* t = funct->GivToken(); + FunctionName = t->GivString(); -// if ( p->m_instr != NULL ) instr = p->m_instr; +// if ( p->m_instr != NULL ) instr = p->m_instr; - t = instr->GivToken(); - start = t->GivStart(); - end = t->GivEnd(); + t = instr->GivToken(); + start = t->GivStart(); + end = t->GivEnd(); } CBotVar* CBotStack::GivStackVars(const char* &FunctionName, int level) { - CBotProgram* prog = m_prog; // programme courrant - FunctionName = NULL; + CBotProgram* prog = m_prog; // programme courrant + FunctionName = NULL; - // remonte la pile dans le module courant - CBotStack* p = this; + // remonte la pile dans le module courant + CBotStack* p = this; - while (p->m_next != NULL) - { - if ( p->m_next->m_prog != prog ) break ; + while (p->m_next != NULL) + { + if ( p->m_next->m_prog != prog ) break ; - if (p->m_next2 && p->m_next2->m_state != 0) p = p->m_next2 ; - else p = p->m_next; - } + if (p->m_next2 && p->m_next2->m_state != 0) p = p->m_next2 ; + else p = p->m_next; + } - // descend sur les éléments de block - while ( p != NULL && !p->m_bBlock ) p = p->m_prev; + // descend sur les éléments de block + while ( p != NULL && !p->m_bBlock ) p = p->m_prev; - while ( p != NULL && level++ < 0 ) - { - p = p->m_prev; - while ( p != NULL && !p->m_bBlock ) p = p->m_prev; - } + while ( p != NULL && level++ < 0 ) + { + p = p->m_prev; + while ( p != NULL && !p->m_bBlock ) p = p->m_prev; + } - if ( p == NULL ) return NULL; + if ( p == NULL ) return NULL; - // recherche le nom de la fonction courante - CBotStack* pp = p; - while ( pp != NULL ) - { - if ( pp->m_bFunc == 1 ) break; - pp = pp->m_prev; - } + // recherche le nom de la fonction courante + CBotStack* pp = p; + while ( pp != NULL ) + { + if ( pp->m_bFunc == 1 ) break; + pp = pp->m_prev; + } - if ( pp == NULL || pp->m_instr == NULL ) return NULL; + if ( pp == NULL || pp->m_instr == NULL ) return NULL; - CBotToken* t = pp->m_instr->GivToken(); - FunctionName = t->GivString(); - - return p->m_listVar; + CBotToken* t = pp->m_instr->GivToken(); + FunctionName = t->GivString(); + + return p->m_listVar; } bool CBotStack::SaveState(FILE* pf) { - if ( this == NULL ) // fin de l'arbre ? - { - return WriteWord(pf, 0); // met un terminateur - } - - if ( m_next2 != NULL ) - { - if (!WriteWord(pf, 2)) return false; // une marque de poursuite - if (!m_next2->SaveState(pf)) return false; - } - else - { - if (!WriteWord(pf, 1)) return false; // une marque de poursuite - } - if (!WriteWord(pf, m_bBlock)) return false; // est-ce un bloc local - if (!WriteWord(pf, m_state)) return false; // dans quel état - if (!WriteWord(pf, 0)) return false; // par compatibilité m_bDontDelete - if (!WriteWord(pf, m_step)) return false; // dans quel état - - - if (!SaveVar(pf, m_var)) return false; // le résultat courant - if (!SaveVar(pf, m_listVar)) return false; // les variables locales - - return m_next->SaveState(pf); // enregistre la suite + if ( this == NULL ) // fin de l'arbre ? + { + return WriteWord(pf, 0); // met un terminateur + } + + if ( m_next2 != NULL ) + { + if (!WriteWord(pf, 2)) return false; // une marque de poursuite + if (!m_next2->SaveState(pf)) return false; + } + else + { + if (!WriteWord(pf, 1)) return false; // une marque de poursuite + } + if (!WriteWord(pf, m_bBlock)) return false; // est-ce un bloc local + if (!WriteWord(pf, m_state)) return false; // dans quel état + if (!WriteWord(pf, 0)) return false; // par compatibilité m_bDontDelete + if (!WriteWord(pf, m_step)) return false; // dans quel état + + + if (!SaveVar(pf, m_var)) return false; // le résultat courant + if (!SaveVar(pf, m_listVar)) return false; // les variables locales + + return m_next->SaveState(pf); // enregistre la suite } bool CBotStack::RestoreState(FILE* pf, CBotStack* &pStack) { - unsigned short w; + unsigned short w; - pStack = NULL; - if (!ReadWord(pf, w)) return false; - if ( w == 0 ) return true; + pStack = NULL; + if (!ReadWord(pf, w)) return false; + if ( w == 0 ) return true; -#if STACKMEM - if ( this == NULL ) pStack = FirstStack(); - else pStack = AddStack(); +#if STACKMEM + if ( this == NULL ) pStack = FirstStack(); + else pStack = AddStack(); #else - pStack = new CBotStack(this); + pStack = new CBotStack(this); #endif - if ( w == 2 ) - { - if (!pStack->RestoreState(pf, pStack->m_next2)) return false; - } + if ( w == 2 ) + { + if (!pStack->RestoreState(pf, pStack->m_next2)) return false; + } - if (!ReadWord(pf, w)) return false; // est-ce un bloc local - pStack->m_bBlock = w; + if (!ReadWord(pf, w)) return false; // est-ce un bloc local + pStack->m_bBlock = w; - if (!ReadWord(pf, w)) return false; // dans quel état j'ère ? - pStack->SetState((short)w); // dans le bon état + if (!ReadWord(pf, w)) return false; // dans quel état j'ère ? + pStack->SetState((short)w); // dans le bon état - if (!ReadWord(pf, w)) return false; // dont delete ? - // plus utilisé + if (!ReadWord(pf, w)) return false; // dont delete ? + // plus utilisé - if (!ReadWord(pf, w)) return false; // pas à pas - pStack->m_step = w; + if (!ReadWord(pf, w)) return false; // pas à pas + pStack->m_step = w; - if (!CBotVar::RestoreState(pf, pStack->m_var)) return false; // la variable temp - if (!CBotVar::RestoreState(pf, pStack->m_listVar)) return false;// les variables locales + if (!CBotVar::RestoreState(pf, pStack->m_var)) return false; // la variable temp + if (!CBotVar::RestoreState(pf, pStack->m_listVar)) return false;// les variables locales - return pStack->RestoreState(pf, pStack->m_next); + return pStack->RestoreState(pf, pStack->m_next); } bool CBotVar::Save0State(FILE* pf) -{ - if (!WriteWord(pf, 100+m_mPrivate))return false; // variable privée ? - if (!WriteWord(pf, m_bStatic))return false; // variable static ? - if (!WriteWord(pf, m_type.GivType()))return false; // enregiste le type (toujours non nul) - if (!WriteWord(pf, m_binit))return false; // variable définie ? - return WriteString(pf, m_token->GivString()); // et le nom de la variable +{ + if (!WriteWord(pf, 100+m_mPrivate))return false; // variable privée ? + if (!WriteWord(pf, m_bStatic))return false; // variable static ? + if (!WriteWord(pf, m_type.GivType()))return false; // enregiste le type (toujours non nul) + if (!WriteWord(pf, m_binit))return false; // variable définie ? + return WriteString(pf, m_token->GivString()); // et le nom de la variable } bool CBotVarInt::Save0State(FILE* pf) -{ - if ( !m_defnum.IsEmpty() ) - { - if(!WriteWord(pf, 200 )) return false; // marqueur spécial - if(!WriteString(pf, m_defnum)) return false; // nom de la valeur - } +{ + if ( !m_defnum.IsEmpty() ) + { + if(!WriteWord(pf, 200 )) return false; // marqueur spécial + if(!WriteString(pf, m_defnum)) return false; // nom de la valeur + } - return CBotVar::Save0State(pf); + return CBotVar::Save0State(pf); } bool CBotVarInt::Save1State(FILE* pf) { - return WriteWord(pf, m_val); // la valeur de la variable + return WriteWord(pf, m_val); // la valeur de la variable } bool CBotVarBoolean::Save1State(FILE* pf) { - return WriteWord(pf, m_val); // la valeur de la variable + return WriteWord(pf, m_val); // la valeur de la variable } bool CBotVarFloat::Save1State(FILE* pf) { - return WriteFloat(pf, m_val); // la valeur de la variable + return WriteFloat(pf, m_val); // la valeur de la variable } bool CBotVarString::Save1State(FILE* pf) { - return WriteString(pf, m_val); // la valeur de la variable + return WriteString(pf, m_val); // la valeur de la variable } bool CBotVarClass::Save1State(FILE* pf) { - if ( !WriteType(pf, m_type) ) return false; - if ( !WriteLong(pf, m_ItemIdent) ) return false; + if ( !WriteType(pf, m_type) ) return false; + if ( !WriteLong(pf, m_ItemIdent) ) return false; - return SaveVar(pf, m_pVar); // contenu de l'objet + return SaveVar(pf, m_pVar); // contenu de l'objet } bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) { - unsigned short w, wi, prv, st; - float ww; - CBotString name, s; - - delete pVar; - - pVar = NULL; - CBotVar* pNew = NULL; - CBotVar* pPrev = NULL; - - while ( true ) // recupère toute une liste - { - if (!ReadWord(pf, w)) return false; // privé ou type ? - if ( w == 0 ) return true; - - CBotString defnum; - if ( w == 200 ) - { - if (!ReadString(pf, defnum)) return false; // nombre avec un identifiant - if (!ReadWord(pf, w)) return false; // type - } - - prv = 100; st = 0; - if ( w >= 100 ) - { - prv = w; - if (!ReadWord(pf, st)) return false; // statique - if (!ReadWord(pf, w)) return false; // type - } - - if ( w == CBotTypClass ) w = CBotTypIntrinsic; // forcément intrinsèque - - if (!ReadWord(pf, wi)) return false; // init ? - - if (!ReadString(pf, name)) return false; // nom de la variable - - CBotToken token(name, CBotString()); - - switch (w) - { - case CBotTypInt: - case CBotTypBoolean: - pNew = CBotVar::Create(&token, w); // crée une variable - if (!ReadWord(pf, w)) return false; - pNew->SetValInt((short)w, defnum); - break; - case CBotTypFloat: - pNew = CBotVar::Create(&token, w); // crée une variable - if (!ReadFloat(pf, ww)) return false; - pNew->SetValFloat(ww); - break; - case CBotTypString: - pNew = CBotVar::Create(&token, w); // crée une variable - if (!ReadString(pf, s)) return false; - pNew->SetValString(s); - break; - - // restitue un objet intrinsic ou un élément d'un array - case CBotTypIntrinsic: - case CBotTypArrayBody: - { - CBotTypResult r; - long id; - if (!ReadType(pf, r)) return false; // type complet - if (!ReadLong(pf, id) ) return false; - -// if (!ReadString(pf, s)) return false; - { - CBotVar* p = NULL; - if ( id ) p = CBotVarClass::Find(id) ; - - pNew = new CBotVarClass(&token, r); // crée directement une instance - // attention cptuse = 0 - if ( !RestoreState(pf, ((CBotVarClass*)pNew)->m_pVar)) return false; - pNew->SetIdent(id); - - if ( p != NULL ) - { - delete pNew; - pNew = p; // reprend l'élément connu - } - } - } - break; - - case CBotTypPointer: - case CBotTypNullPointer: - if (!ReadString(pf, s)) return false; - { - pNew = CBotVar::Create(&token, CBotTypResult(w, s));// crée une variable - CBotVarClass* p = NULL; - long id; - ReadLong(pf, id); -// if ( id ) p = CBotVarClass::Find(id); // retrouve l'instance ( fait par RestoreInstance ) - - // restitue une copie de l'instance d'origine - CBotVar* pInstance = NULL; - if ( !CBotVar::RestoreState( pf, pInstance ) ) return false; - ((CBotVarPointer*)pNew)->SetPointer( pInstance ); // et pointe dessus - -// if ( p != NULL ) ((CBotVarPointer*)pNew)->SetPointer( p ); // plutôt celui-ci ! - - } - break; - - case CBotTypArrayPointer: - { - CBotTypResult r; - if (!ReadType(pf, r)) return false; - - pNew = CBotVar::Create(&token, r); // crée une variable - - // restitue une copie de l'instance d'origine - CBotVar* pInstance = NULL; - if ( !CBotVar::RestoreState( pf, pInstance ) ) return false; - ((CBotVarPointer*)pNew)->SetPointer( pInstance ); // et pointe dessus - } - break; - default: - ASM_TRAP(); - } - - if ( pPrev != NULL ) pPrev->m_next = pNew; - if ( pVar == NULL ) pVar = pNew; - - pNew->m_binit = wi; // pNew->SetInit(wi); - pNew->SetStatic(st); - pNew->SetPrivate(prv-100); - pPrev = pNew; - } - return true; + unsigned short w, wi, prv, st; + float ww; + CBotString name, s; + + delete pVar; + + pVar = NULL; + CBotVar* pNew = NULL; + CBotVar* pPrev = NULL; + + while ( true ) // recupère toute une liste + { + if (!ReadWord(pf, w)) return false; // privé ou type ? + if ( w == 0 ) return true; + + CBotString defnum; + if ( w == 200 ) + { + if (!ReadString(pf, defnum)) return false; // nombre avec un identifiant + if (!ReadWord(pf, w)) return false; // type + } + + prv = 100; st = 0; + if ( w >= 100 ) + { + prv = w; + if (!ReadWord(pf, st)) return false; // statique + if (!ReadWord(pf, w)) return false; // type + } + + if ( w == CBotTypClass ) w = CBotTypIntrinsic; // forcément intrinsèque + + if (!ReadWord(pf, wi)) return false; // init ? + + if (!ReadString(pf, name)) return false; // nom de la variable + + CBotToken token(name, CBotString()); + + switch (w) + { + case CBotTypInt: + case CBotTypBoolean: + pNew = CBotVar::Create(&token, w); // crée une variable + if (!ReadWord(pf, w)) return false; + pNew->SetValInt((short)w, defnum); + break; + case CBotTypFloat: + pNew = CBotVar::Create(&token, w); // crée une variable + if (!ReadFloat(pf, ww)) return false; + pNew->SetValFloat(ww); + break; + case CBotTypString: + pNew = CBotVar::Create(&token, w); // crée une variable + if (!ReadString(pf, s)) return false; + pNew->SetValString(s); + break; + + // restitue un objet intrinsic ou un élément d'un array + case CBotTypIntrinsic: + case CBotTypArrayBody: + { + CBotTypResult r; + long id; + if (!ReadType(pf, r)) return false; // type complet + if (!ReadLong(pf, id) ) return false; + +// if (!ReadString(pf, s)) return false; + { + CBotVar* p = NULL; + if ( id ) p = CBotVarClass::Find(id) ; + + pNew = new CBotVarClass(&token, r); // crée directement une instance + // attention cptuse = 0 + if ( !RestoreState(pf, ((CBotVarClass*)pNew)->m_pVar)) return false; + pNew->SetIdent(id); + + if ( p != NULL ) + { + delete pNew; + pNew = p; // reprend l'élément connu + } + } + } + break; + + case CBotTypPointer: + case CBotTypNullPointer: + if (!ReadString(pf, s)) return false; + { + pNew = CBotVar::Create(&token, CBotTypResult(w, s));// crée une variable + CBotVarClass* p = NULL; + long id; + ReadLong(pf, id); +// if ( id ) p = CBotVarClass::Find(id); // retrouve l'instance ( fait par RestoreInstance ) + + // restitue une copie de l'instance d'origine + CBotVar* pInstance = NULL; + if ( !CBotVar::RestoreState( pf, pInstance ) ) return false; + ((CBotVarPointer*)pNew)->SetPointer( pInstance ); // et pointe dessus + +// if ( p != NULL ) ((CBotVarPointer*)pNew)->SetPointer( p ); // plutôt celui-ci ! + + } + break; + + case CBotTypArrayPointer: + { + CBotTypResult r; + if (!ReadType(pf, r)) return false; + + pNew = CBotVar::Create(&token, r); // crée une variable + + // restitue une copie de l'instance d'origine + CBotVar* pInstance = NULL; + if ( !CBotVar::RestoreState( pf, pInstance ) ) return false; + ((CBotVarPointer*)pNew)->SetPointer( pInstance ); // et pointe dessus + } + break; + default: + ASM_TRAP(); + } + + if ( pPrev != NULL ) pPrev->m_next = pNew; + if ( pVar == NULL ) pVar = pNew; + + pNew->m_binit = wi; // pNew->SetInit(wi); + pNew->SetStatic(st); + pNew->SetPrivate(prv-100); + pPrev = pNew; + } + return true; } @@ -1123,11 +1112,11 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) // gestion de la pile à la compilation //////////////////////////////////////////////////////////////////////////// -CBotProgram* CBotCStack::m_prog = NULL; // init la variable statique -int CBotCStack::m_error = 0; -int CBotCStack::m_end = 0; -CBotTypResult CBotCStack::m_retTyp = CBotTypResult(0); -//CBotToken* CBotCStack::m_retClass= NULL; +CBotProgram* CBotCStack::m_prog = NULL; // init la variable statique +int CBotCStack::m_error = 0; +int CBotCStack::m_end = 0; +CBotTypResult CBotCStack::m_retTyp = CBotTypResult(0); +//CBotToken* CBotCStack::m_retClass= NULL; CBotCStack::CBotCStack(CBotCStack* ppapa) @@ -1135,125 +1124,125 @@ CBotCStack::CBotCStack(CBotCStack* ppapa) m_next = NULL; m_prev = ppapa; - if (ppapa == NULL) - { - m_error = 0; - m_start = 0; - m_end = 0; - m_bBlock = true; - } - else - { - m_start = ppapa->m_start; - m_bBlock = false; - } + if (ppapa == NULL) + { + m_error = 0; + m_start = 0; + m_end = 0; + m_bBlock = true; + } + else + { + m_start = ppapa->m_start; + m_bBlock = false; + } - m_listVar = NULL; - m_var = NULL; + m_listVar = NULL; + m_var = NULL; } // destructeur CBotCStack::~CBotCStack() { - if (m_next != NULL) delete m_next; - if (m_prev != NULL) m_prev->m_next = NULL; // enlève de la chaîne + if (m_next != NULL) delete m_next; + if (m_prev != NULL) m_prev->m_next = NULL; // enlève de la chaîne - delete m_var; - delete m_listVar; + delete m_var; + delete m_listVar; } // utilisé uniquement à la compilation CBotCStack* CBotCStack::TokenStack(CBotToken* pToken, bool bBlock) { - if (m_next != NULL) return m_next; // reprise dans une pile existante + if (m_next != NULL) return m_next; // reprise dans une pile existante - CBotCStack* p = new CBotCStack(this); - m_next = p; // chaîne l'élément - p->m_bBlock = bBlock; + CBotCStack* p = new CBotCStack(this); + m_next = p; // chaîne l'élément + p->m_bBlock = bBlock; - if (pToken != NULL) p->SetStartError(pToken->GivStart()); + if (pToken != NULL) p->SetStartError(pToken->GivStart()); - return p; + return p; } CBotInstr* CBotCStack::Return(CBotInstr* inst, CBotCStack* pfils) -{ - if ( pfils == this ) return inst; +{ + if ( pfils == this ) return inst; - if (m_var != NULL) delete m_var; // valeur remplacée ? - m_var = pfils->m_var; // résultat transmis - pfils->m_var = NULL; // ne pas détruire la variable + if (m_var != NULL) delete m_var; // valeur remplacée ? + m_var = pfils->m_var; // résultat transmis + pfils->m_var = NULL; // ne pas détruire la variable - if (m_error) - { - m_start = pfils->m_start; // récupère la position de l'erreur - m_end = pfils->m_end; - } + if (m_error) + { + m_start = pfils->m_start; // récupère la position de l'erreur + m_end = pfils->m_end; + } - delete pfils; - return inst; + delete pfils; + return inst; } CBotFunction* CBotCStack::ReturnFunc(CBotFunction* inst, CBotCStack* pfils) -{ - if (m_var != NULL) delete m_var; // valeur remplacée ? - m_var = pfils->m_var; // résultat transmis - pfils->m_var = NULL; // ne pas détruire la variable +{ + if (m_var != NULL) delete m_var; // valeur remplacée ? + m_var = pfils->m_var; // résultat transmis + pfils->m_var = NULL; // ne pas détruire la variable - if (m_error) - { - m_start = pfils->m_start; // récupère la position de l'erreur - m_end = pfils->m_end; - } + if (m_error) + { + m_start = pfils->m_start; // récupère la position de l'erreur + m_end = pfils->m_end; + } - delete pfils; - return inst; + delete pfils; + return inst; } int CBotCStack::GivError(int& start, int& end) { - start = m_start; - end = m_end; - return m_error; + start = m_start; + end = m_end; + return m_error; } int CBotCStack::GivError() { - return m_error; + return m_error; } // type d'instruction sur la pile CBotTypResult CBotCStack::GivTypResult(int mode) { - if (m_var == NULL) - return CBotTypResult(99); - return m_var->GivTypResult(mode); + if (m_var == NULL) + return CBotTypResult(99); + return m_var->GivTypResult(mode); } // type d'instruction sur la pile int CBotCStack::GivType(int mode) { - if (m_var == NULL) - return 99; - return m_var->GivType(mode); + if (m_var == NULL) + return 99; + return m_var->GivType(mode); } // pointeur sur la pile est de quelle classe ? CBotClass* CBotCStack::GivClass() { - if ( m_var == NULL ) - return NULL; - if ( m_var->GivType(1) != CBotTypPointer ) return NULL; + if ( m_var == NULL ) + return NULL; + if ( m_var->GivType(1) != CBotTypPointer ) return NULL; - return m_var->GivClass(); + return m_var->GivClass(); } // type d'instruction sur la pile void CBotCStack::SetType(CBotTypResult& type) { - if (m_var == NULL) return; - m_var->SetType( type ); + if (m_var == NULL) return; + m_var->SetType( type ); } // cherche une variable sur la pile @@ -1262,40 +1251,40 @@ void CBotCStack::SetType(CBotTypResult& type) CBotVar* CBotCStack::FindVar(CBotToken* &pToken) { - CBotCStack* p = this; - CBotString name = pToken->GivString(); - - while (p != NULL) - { - CBotVar* pp = p->m_listVar; - while ( pp != NULL) - { - if (name == pp->GivName()) - { - return pp; - } - pp = pp->m_next; - } - p = p->m_prev; - } - return NULL; + CBotCStack* p = this; + CBotString name = pToken->GivString(); + + while (p != NULL) + { + CBotVar* pp = p->m_listVar; + while ( pp != NULL) + { + if (name == pp->GivName()) + { + return pp; + } + pp = pp->m_next; + } + p = p->m_prev; + } + return NULL; } CBotVar* CBotCStack::FindVar(CBotToken& Token) { - CBotToken* pt = &Token; - return FindVar(pt); + CBotToken* pt = &Token; + return FindVar(pt); } CBotVar* CBotCStack::CopyVar(CBotToken& Token) { - CBotVar* pVar = FindVar( Token ); + CBotVar* pVar = FindVar( Token ); - if ( pVar == NULL) return NULL; + if ( pVar == NULL) return NULL; - CBotVar* pCopy = CBotVar::Create( "", pVar->GivType() ); - pCopy->Copy(pVar); - return pCopy; + CBotVar* pCopy = CBotVar::Create( "", pVar->GivType() ); + pCopy->Copy(pVar); + return pCopy; } bool CBotCStack::IsOk() @@ -1306,100 +1295,100 @@ bool CBotCStack::IsOk() void CBotCStack::SetStartError( int pos ) { - if ( m_error != 0) return; // ne change pas une erreur déjà existante - m_start = pos; + if ( m_error != 0) return; // ne change pas une erreur déjà existante + m_start = pos; } void CBotCStack::SetError(int n, int pos) { - if ( n!= 0 && m_error != 0) return; // ne change pas une erreur déjà existante - m_error = n; - m_end = pos; + if ( n!= 0 && m_error != 0) return; // ne change pas une erreur déjà existante + m_error = n; + m_end = pos; } void CBotCStack::SetError(int n, CBotToken* p) { - if (m_error) return; // ne change pas une erreur déjà existante - m_error = n; - m_start = p->GivStart(); - m_end = p->GivEnd(); + if (m_error) return; // ne change pas une erreur déjà existante + m_error = n; + m_start = p->GivStart(); + m_end = p->GivEnd(); } void CBotCStack::ResetError(int n, int start, int end) { - m_error = n; - m_start = start; - m_end = end; + m_error = n; + m_start = start; + m_end = end; } bool CBotCStack::NextToken(CBotToken* &p) { - CBotToken* pp = p; + CBotToken* pp = p; - p = p->GivNext(); - if (p!=NULL) return true; + p = p->GivNext(); + if (p!=NULL) return true; - SetError(TX_ENDOF, pp->GivEnd()); - return false; + SetError(TX_ENDOF, pp->GivEnd()); + return false; } void CBotCStack::SetBotCall(CBotProgram* p) { - m_prog = p; + m_prog = p; } CBotProgram* CBotCStack::GivBotCall() { - return m_prog; + return m_prog; } void CBotCStack::SetRetType(CBotTypResult& type) { - m_retTyp = type; + m_retTyp = type; } CBotTypResult CBotCStack::GivRetType() { - return m_retTyp; + return m_retTyp; } void CBotCStack::SetVar( CBotVar* var ) { - if (m_var) delete m_var; // remplacement d'une variable - m_var = var; + if (m_var) delete m_var; // remplacement d'une variable + m_var = var; } // met sur le stack une copie d'une variable void CBotCStack::SetCopyVar( CBotVar* var ) { - if (m_var) delete m_var; // remplacement d'une variable + if (m_var) delete m_var; // remplacement d'une variable - if ( var == NULL ) return; - m_var = CBotVar::Create("", var->GivTypResult(2)); - m_var->Copy( var ); + if ( var == NULL ) return; + m_var = CBotVar::Create("", var->GivTypResult(2)); + m_var->Copy( var ); } CBotVar* CBotCStack::GivVar() { - return m_var; + return m_var; } void CBotCStack::AddVar(CBotVar* pVar) { - CBotCStack* p = this; + CBotCStack* p = this; - // revient sur l'élement père - while (p != NULL && p->m_bBlock == 0) p = p->m_prev; + // revient sur l'élement père + while (p != NULL && p->m_bBlock == 0) p = p->m_prev; - if ( p == NULL ) return; + if ( p == NULL ) return; - CBotVar** pp = &p->m_listVar; - while ( *pp != NULL ) pp = &(*pp)->m_next; + CBotVar** pp = &p->m_listVar; + while ( *pp != NULL ) pp = &(*pp)->m_next; - *pp = pVar; // ajoute à la suite + *pp = pVar; // ajoute à la suite -#ifdef _DEBUG - if ( pVar->GivUniqNum() == 0 ) ASM_TRAP(); +#ifdef _DEBUG + if ( pVar->GivUniqNum() == 0 ) ASM_TRAP(); #endif } @@ -1407,76 +1396,76 @@ void CBotCStack::AddVar(CBotVar* pVar) bool CBotCStack::CheckVarLocal(CBotToken* &pToken) { - CBotCStack* p = this; - CBotString name = pToken->GivString(); + CBotCStack* p = this; + CBotString name = pToken->GivString(); - while (p != NULL) - { - CBotVar* pp = p->m_listVar; - while ( pp != NULL) - { - if (name == pp->GivName()) - return true; - pp = pp->m_next; - } - if ( p->m_bBlock ) return false; - p = p->m_prev; - } - return false; + while (p != NULL) + { + CBotVar* pp = p->m_listVar; + while ( pp != NULL) + { + if (name == pp->GivName()) + return true; + pp = pp->m_next; + } + if ( p->m_bBlock ) return false; + p = p->m_prev; + } + return false; } CBotTypResult CBotCStack::CompileCall(CBotToken* &p, CBotVar** ppVars, long& nIdent) { - nIdent = 0; - CBotTypResult val(-1); + nIdent = 0; + CBotTypResult val(-1); - val = CBotCall::CompileCall(p, ppVars, this, nIdent); - if (val.GivType() < 0) - { - val = m_prog->GivFunctions()->CompileCall(p->GivString(), ppVars, nIdent); - if ( val.GivType() < 0 ) - { - // pVar = NULL; // l'erreur n'est pas sur un paramètre en particulier - SetError( -val.GivType(), p ); - val.SetType(-val.GivType()); - return val; - } - } - return val; + val = CBotCall::CompileCall(p, ppVars, this, nIdent); + if (val.GivType() < 0) + { + val = m_prog->GivFunctions()->CompileCall(p->GivString(), ppVars, nIdent); + if ( val.GivType() < 0 ) + { + // pVar = NULL; // l'erreur n'est pas sur un paramètre en particulier + SetError( -val.GivType(), p ); + val.SetType(-val.GivType()); + return val; + } + } + return val; } // test si un nom de procédure est déjà défini quelque part bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam) { - CBotString name = pToken->GivString(); - - if ( CBotCall::CheckCall(name) ) return true; - - CBotFunction* pp = m_prog->GivFunctions(); - while ( pp != NULL ) - { - if ( pToken->GivString() == pp->GivName() ) - { - // les paramètres sont-ils exactement les mêmes ? - if ( pp->CheckParam( pParam ) ) - return true; - } - pp = pp->Next(); - } - - pp = CBotFunction::m_listPublic; - while ( pp != NULL ) - { - if ( pToken->GivString() == pp->GivName() ) - { - // les paramètres sont-ils exactement les mêmes ? - if ( pp->CheckParam( pParam ) ) - return true; - } - pp = pp->m_nextpublic; - } - - return false; + CBotString name = pToken->GivString(); + + if ( CBotCall::CheckCall(name) ) return true; + + CBotFunction* pp = m_prog->GivFunctions(); + while ( pp != NULL ) + { + if ( pToken->GivString() == pp->GivName() ) + { + // les paramètres sont-ils exactement les mêmes ? + if ( pp->CheckParam( pParam ) ) + return true; + } + pp = pp->Next(); + } + + pp = CBotFunction::m_listPublic; + while ( pp != NULL ) + { + if ( pToken->GivString() == pp->GivName() ) + { + // les paramètres sont-ils exactement les mêmes ? + if ( pp->CheckParam( pParam ) ) + return true; + } + pp = pp->m_nextpublic; + } + + return false; } diff --git a/src/CBot/CBotString.cpp b/src/CBot/CBotString.cpp index 33e1d04..9d5d257 100644 --- a/src/CBot/CBotString.cpp +++ b/src/CBot/CBotString.cpp @@ -23,7 +23,7 @@ #include //Map is filled with id-string pars that are needed for CBot language parsing -const std::map CBotString::s_keywordString = +const std::map CBotString::s_keywordString = { {ID_IF, "if"}, {ID_ELSE, "else"}, @@ -113,9 +113,9 @@ const std::map CBotString::s_keywordString = {ID_MODULO, "%"}, {ID_POWER, "**"}, {ID_ASSMODULO, "%="}, + {ID_SUPER, "super"}, {TX_UNDEF, "undefined"}, - {TX_NAN, "not a number"}, - {ID_SUPER, "super"} + {TX_NAN, "not a number"} }; CBotString::CBotString() diff --git a/src/CBot/CBotVar.cpp b/src/CBot/CBotVar.cpp index 79ba021..9070298 100644 --- a/src/CBot/CBotVar.cpp +++ b/src/CBot/CBotVar.cpp @@ -27,80 +27,80 @@ long CBotVar::m_identcpt = 0; CBotVar::CBotVar( ) { - m_next = NULL; - m_pMyThis = NULL; - m_pUserPtr = NULL; - m_InitExpr = NULL; - m_LimExpr = NULL; - m_type = -1; - m_binit = false; - m_ident = 0; - m_bStatic = false; - m_mPrivate = 0; + m_next = NULL; + m_pMyThis = NULL; + m_pUserPtr = NULL; + m_InitExpr = NULL; + m_LimExpr = NULL; + m_type = -1; + m_binit = false; + m_ident = 0; + m_bStatic = false; + m_mPrivate = 0; } CBotVarInt::CBotVarInt( const CBotToken* name ) { - m_token = new CBotToken(name); - m_next = NULL; - m_pMyThis = NULL; - m_pUserPtr = NULL; - m_InitExpr = NULL; - m_LimExpr = NULL; - m_type = CBotTypInt; - m_binit = false; - m_bStatic = false; - m_mPrivate = 0; + m_token = new CBotToken(name); + m_next = NULL; + m_pMyThis = NULL; + m_pUserPtr = NULL; + m_InitExpr = NULL; + m_LimExpr = NULL; + m_type = CBotTypInt; + m_binit = false; + m_bStatic = false; + m_mPrivate = 0; - m_val = 0; + m_val = 0; } CBotVarFloat::CBotVarFloat( const CBotToken* name ) { - m_token = new CBotToken(name); - m_next = NULL; - m_pMyThis = NULL; - m_pUserPtr = NULL; - m_InitExpr = NULL; - m_LimExpr = NULL; - m_type = CBotTypFloat; - m_binit = false; - m_bStatic = false; - m_mPrivate = 0; + m_token = new CBotToken(name); + m_next = NULL; + m_pMyThis = NULL; + m_pUserPtr = NULL; + m_InitExpr = NULL; + m_LimExpr = NULL; + m_type = CBotTypFloat; + m_binit = false; + m_bStatic = false; + m_mPrivate = 0; - m_val = 0; + m_val = 0; } CBotVarString::CBotVarString( const CBotToken* name ) { - m_token = new CBotToken(name); - m_next = NULL; - m_pMyThis = NULL; - m_pUserPtr = NULL; - m_InitExpr = NULL; - m_LimExpr = NULL; - m_type = CBotTypString; - m_binit = false; - m_bStatic = false; - m_mPrivate = 0; + m_token = new CBotToken(name); + m_next = NULL; + m_pMyThis = NULL; + m_pUserPtr = NULL; + m_InitExpr = NULL; + m_LimExpr = NULL; + m_type = CBotTypString; + m_binit = false; + m_bStatic = false; + m_mPrivate = 0; - m_val.Empty(); + m_val.Empty(); } CBotVarBoolean::CBotVarBoolean( const CBotToken* name ) { - m_token = new CBotToken(name); - m_next = NULL; - m_pMyThis = NULL; - m_pUserPtr = NULL; - m_InitExpr = NULL; - m_LimExpr = NULL; - m_type = CBotTypBoolean; - m_binit = false; - m_bStatic = false; - m_mPrivate = 0; + m_token = new CBotToken(name); + m_next = NULL; + m_pMyThis = NULL; + m_pUserPtr = NULL; + m_InitExpr = NULL; + m_LimExpr = NULL; + m_type = CBotTypBoolean; + m_binit = false; + m_bStatic = false; + m_mPrivate = 0; - m_val = 0; + m_val = 0; } CBotVarClass* CBotVarClass::m_ExClass = NULL; @@ -108,171 +108,171 @@ CBotVarClass* CBotVarClass::m_ExClass = NULL; CBotVarClass::CBotVarClass( const CBotToken* name, const CBotTypResult& type) { /* -// int nIdent = 0; - InitCBotVarClass( name, type ) //, nIdent ); +// int nIdent = 0; + InitCBotVarClass( name, type ) //, nIdent ); } CBotVarClass::CBotVarClass( const CBotToken* name, CBotTypResult& type) //, int &nIdent ) { - InitCBotVarClass( name, type ); //, nIdent ); + InitCBotVarClass( name, type ); //, nIdent ); } void CBotVarClass::InitCBotVarClass( const CBotToken* name, CBotTypResult& type ) //, int &nIdent ) {*/ - if ( !type.Eq(CBotTypClass) && - !type.Eq(CBotTypIntrinsic) && // par comodité accepte ces types - !type.Eq(CBotTypPointer) && - !type.Eq(CBotTypArrayPointer) && - !type.Eq(CBotTypArrayBody)) ASM_TRAP(); - - m_token = new CBotToken(name); - m_next = NULL; - m_pMyThis = NULL; - m_pUserPtr = OBJECTCREATED;//NULL; - m_InitExpr = NULL; - m_LimExpr = NULL; - m_pVar = NULL; - m_type = type; - if ( type.Eq(CBotTypArrayPointer) ) m_type.SetType( CBotTypArrayBody ); - else if ( !type.Eq(CBotTypArrayBody) ) m_type.SetType( CBotTypClass ); - // type officel pour cet object - - m_pClass = NULL; - m_pParent = NULL; - m_binit = false; - m_bStatic = false; - m_mPrivate = 0; - m_bConstructor = false; - m_CptUse = 0; - m_ItemIdent = type.Eq(CBotTypIntrinsic) ? 0 : CBotVar::NextUniqNum(); - - // se place tout seul dans la liste - if (m_ExClass) m_ExClass->m_ExPrev = this; - m_ExNext = m_ExClass; - m_ExPrev = NULL; - m_ExClass = this; - - CBotClass* pClass = type.GivClass(); - CBotClass* pClass2 = pClass->GivParent(); - if ( pClass2 != NULL ) - { - // crée également une instance dans la classe père - m_pParent = new CBotVarClass(name, CBotTypResult(type.GivType(),pClass2) ); //, nIdent); - } - - SetClass( pClass ); //, nIdent ); + if ( !type.Eq(CBotTypClass) && + !type.Eq(CBotTypIntrinsic) && // par comodité accepte ces types + !type.Eq(CBotTypPointer) && + !type.Eq(CBotTypArrayPointer) && + !type.Eq(CBotTypArrayBody)) ASM_TRAP(); + + m_token = new CBotToken(name); + m_next = NULL; + m_pMyThis = NULL; + m_pUserPtr = OBJECTCREATED;//NULL; + m_InitExpr = NULL; + m_LimExpr = NULL; + m_pVar = NULL; + m_type = type; + if ( type.Eq(CBotTypArrayPointer) ) m_type.SetType( CBotTypArrayBody ); + else if ( !type.Eq(CBotTypArrayBody) ) m_type.SetType( CBotTypClass ); + // type officel pour cet object + + m_pClass = NULL; + m_pParent = NULL; + m_binit = false; + m_bStatic = false; + m_mPrivate = 0; + m_bConstructor = false; + m_CptUse = 0; + m_ItemIdent = type.Eq(CBotTypIntrinsic) ? 0 : CBotVar::NextUniqNum(); + + // se place tout seul dans la liste + if (m_ExClass) m_ExClass->m_ExPrev = this; + m_ExNext = m_ExClass; + m_ExPrev = NULL; + m_ExClass = this; + + CBotClass* pClass = type.GivClass(); + CBotClass* pClass2 = pClass->GivParent(); + if ( pClass2 != NULL ) + { + // crée également une instance dans la classe père + m_pParent = new CBotVarClass(name, CBotTypResult(type.GivType(),pClass2) ); //, nIdent); + } + + SetClass( pClass ); //, nIdent ); } CBotVarClass::~CBotVarClass( ) { - if ( m_CptUse != 0 ) - ASM_TRAP(); + if ( m_CptUse != 0 ) + ASM_TRAP(); - if ( m_pParent ) delete m_pParent; - m_pParent = NULL; + if ( m_pParent ) delete m_pParent; + m_pParent = NULL; - // libère l'objet indirect s'il y a lieu -// if ( m_Indirect != NULL ) -// m_Indirect->DecrementUse(); + // libère l'objet indirect s'il y a lieu +// if ( m_Indirect != NULL ) +// m_Indirect->DecrementUse(); - // retire la classe de la liste - if ( m_ExPrev ) m_ExPrev->m_ExNext = m_ExNext; - else m_ExClass = m_ExNext; + // retire la classe de la liste + if ( m_ExPrev ) m_ExPrev->m_ExNext = m_ExNext; + else m_ExClass = m_ExNext; - if ( m_ExNext ) m_ExNext->m_ExPrev = m_ExPrev; - m_ExPrev = NULL; - m_ExNext = NULL; + if ( m_ExNext ) m_ExNext->m_ExPrev = m_ExPrev; + m_ExPrev = NULL; + m_ExNext = NULL; - delete m_pVar; + delete m_pVar; } void CBotVarClass::ConstructorSet() { - m_bConstructor = true; + m_bConstructor = true; } CBotVar::~CBotVar( ) { - delete m_token; - delete m_next; + delete m_token; + delete m_next; } void CBotVar::debug() { - const char* p = (const char*) m_token->GivString(); - CBotString s = (const char*) GivValString(); - const char* v = (const char*) s; + const char* p = (const char*) m_token->GivString(); + CBotString s = (const char*) GivValString(); + const char* v = (const char*) s; - if ( m_type.Eq(CBotTypClass) ) - { - CBotVar* pv = ((CBotVarClass*)this)->m_pVar; - while (pv != NULL) - { - pv->debug(); - pv = pv->GivNext(); - } - } + if ( m_type.Eq(CBotTypClass) ) + { + CBotVar* pv = ((CBotVarClass*)this)->m_pVar; + while (pv != NULL) + { + pv->debug(); + pv = pv->GivNext(); + } + } } void CBotVar::ConstructorSet() { - // nop + // nop } void CBotVar::SetUserPtr(void* pUser) { - m_pUserPtr = pUser; - if (m_type.Eq(CBotTypPointer) && - ((CBotVarPointer*)this)->m_pVarClass != NULL ) - ((CBotVarPointer*)this)->m_pVarClass->SetUserPtr(pUser); + m_pUserPtr = pUser; + if (m_type.Eq(CBotTypPointer) && + ((CBotVarPointer*)this)->m_pVarClass != NULL ) + ((CBotVarPointer*)this)->m_pVarClass->SetUserPtr(pUser); } void CBotVar::SetIdent(long n) { - if (m_type.Eq(CBotTypPointer) && - ((CBotVarPointer*)this)->m_pVarClass != NULL ) - ((CBotVarPointer*)this)->m_pVarClass->SetIdent(n); + if (m_type.Eq(CBotTypPointer) && + ((CBotVarPointer*)this)->m_pVarClass != NULL ) + ((CBotVarPointer*)this)->m_pVarClass->SetIdent(n); } void CBotVar::SetUniqNum(long n) { - m_ident = n; + m_ident = n; - if ( n == 0 ) ASM_TRAP(); + if ( n == 0 ) ASM_TRAP(); } long CBotVar::NextUniqNum() { - if (++m_identcpt < 10000) m_identcpt = 10000; - return m_identcpt; + if (++m_identcpt < 10000) m_identcpt = 10000; + return m_identcpt; } long CBotVar::GivUniqNum() { - return m_ident; + return m_ident; } void* CBotVar::GivUserPtr() { - return m_pUserPtr; + return m_pUserPtr; } bool CBotVar::Save1State(FILE* pf) { - // cette routine "virtual" ne doit jamais être appellée, - // il doit y avoir une routine pour chaque classe fille (CBotVarInt, CBotVarFloat, etc) - // ( voir le type dans m_type ) - ASM_TRAP(); - return false; + // cette routine "virtual" ne doit jamais être appellée, + // il doit y avoir une routine pour chaque classe fille (CBotVarInt, CBotVarFloat, etc) + // ( voir le type dans m_type ) + ASM_TRAP(); + return false; } void CBotVar::Maj(void* pUser, bool bContinu) { -/* if (!bContinu && m_pMyThis != NULL) - m_pMyThis->Maj(pUser, true);*/ +/* if (!bContinu && m_pMyThis != NULL) + m_pMyThis->Maj(pUser, true);*/ } @@ -280,382 +280,382 @@ void CBotVar::Maj(void* pUser, bool bContinu) CBotVar* CBotVar::Create(const CBotToken* name, int type ) { - CBotTypResult t(type); - return Create(name, t); + CBotTypResult t(type); + return Create(name, t); } CBotVar* CBotVar::Create(const CBotToken* name, CBotTypResult type) { - switch (type.GivType()) - { - case CBotTypShort: - case CBotTypInt: - return new CBotVarInt(name); - case CBotTypFloat: - return new CBotVarFloat(name); - case CBotTypBoolean: - return new CBotVarBoolean(name); - case CBotTypString: - return new CBotVarString(name); - case CBotTypPointer: - case CBotTypNullPointer: - return new CBotVarPointer(name, type); - case CBotTypIntrinsic: - return new CBotVarClass(name, type); - - case CBotTypClass: - // crée une nouvelle instance d'une classe - // et retourne le POINTER sur cette instance - { - CBotVarClass* instance = new CBotVarClass(name, type); - CBotVarPointer* pointer = new CBotVarPointer(name, type); - pointer->SetPointer( instance ); - return pointer; - } - - case CBotTypArrayPointer: - return new CBotVarArray(name, type); - - case CBotTypArrayBody: - { - CBotVarClass* instance = new CBotVarClass(name, type); - CBotVarArray* array = new CBotVarArray(name, type); - array->SetPointer( instance ); - - CBotVar* pv = array; - while (type.Eq(CBotTypArrayBody)) - { - type = type.GivTypElem(); - pv = ((CBotVarArray*)pv)->GivItem(0, true); // crée au moins l'élément [0] - } - - return array; - } - } - - ASM_TRAP(); - return NULL; + switch (type.GivType()) + { + case CBotTypShort: + case CBotTypInt: + return new CBotVarInt(name); + case CBotTypFloat: + return new CBotVarFloat(name); + case CBotTypBoolean: + return new CBotVarBoolean(name); + case CBotTypString: + return new CBotVarString(name); + case CBotTypPointer: + case CBotTypNullPointer: + return new CBotVarPointer(name, type); + case CBotTypIntrinsic: + return new CBotVarClass(name, type); + + case CBotTypClass: + // crée une nouvelle instance d'une classe + // et retourne le POINTER sur cette instance + { + CBotVarClass* instance = new CBotVarClass(name, type); + CBotVarPointer* pointer = new CBotVarPointer(name, type); + pointer->SetPointer( instance ); + return pointer; + } + + case CBotTypArrayPointer: + return new CBotVarArray(name, type); + + case CBotTypArrayBody: + { + CBotVarClass* instance = new CBotVarClass(name, type); + CBotVarArray* array = new CBotVarArray(name, type); + array->SetPointer( instance ); + + CBotVar* pv = array; + while (type.Eq(CBotTypArrayBody)) + { + type = type.GivTypElem(); + pv = ((CBotVarArray*)pv)->GivItem(0, true); // crée au moins l'élément [0] + } + + return array; + } + } + + ASM_TRAP(); + return NULL; } CBotVar* CBotVar::Create( CBotVar* pVar ) { - CBotVar* p = Create(pVar->m_token->GivString(), pVar->GivTypResult(2)); - return p; + CBotVar* p = Create(pVar->m_token->GivString(), pVar->GivTypResult(2)); + return p; } CBotVar* CBotVar::Create( const char* n, CBotTypResult type) { - CBotToken name(n); - - switch (type.GivType()) - { - case CBotTypShort: - case CBotTypInt: - return new CBotVarInt(&name); - case CBotTypFloat: - return new CBotVarFloat(&name); - case CBotTypBoolean: - return new CBotVarBoolean(&name); - case CBotTypString: - return new CBotVarString(&name); - case CBotTypPointer: - case CBotTypNullPointer: - { - CBotVarPointer* p = new CBotVarPointer(&name, type); -// p->SetClass(type.GivClass()); - return p; - } - case CBotTypIntrinsic: - { - CBotVarClass* p = new CBotVarClass(&name, type); -// p->SetClass(type.GivClass()); - return p; - } - - case CBotTypClass: - // crée une nouvelle instance d'une classe - // et retourne le POINTER sur cette instance - { - CBotVarClass* instance = new CBotVarClass(&name, type); - CBotVarPointer* pointer = new CBotVarPointer(&name, type); - pointer->SetPointer( instance ); -// pointer->SetClass( type.GivClass() ); - return pointer; - } - - case CBotTypArrayPointer: - return new CBotVarArray(&name, type); - - case CBotTypArrayBody: - { - CBotVarClass* instance = new CBotVarClass(&name, type); - CBotVarArray* array = new CBotVarArray(&name, type); - array->SetPointer( instance ); - - CBotVar* pv = array; - while (type.Eq(CBotTypArrayBody)) - { - type = type.GivTypElem(); - pv = ((CBotVarArray*)pv)->GivItem(0, true); // crée au moins l'élément [0] - } - - return array; - } - } - - ASM_TRAP(); - return NULL; + CBotToken name(n); + + switch (type.GivType()) + { + case CBotTypShort: + case CBotTypInt: + return new CBotVarInt(&name); + case CBotTypFloat: + return new CBotVarFloat(&name); + case CBotTypBoolean: + return new CBotVarBoolean(&name); + case CBotTypString: + return new CBotVarString(&name); + case CBotTypPointer: + case CBotTypNullPointer: + { + CBotVarPointer* p = new CBotVarPointer(&name, type); +// p->SetClass(type.GivClass()); + return p; + } + case CBotTypIntrinsic: + { + CBotVarClass* p = new CBotVarClass(&name, type); +// p->SetClass(type.GivClass()); + return p; + } + + case CBotTypClass: + // crée une nouvelle instance d'une classe + // et retourne le POINTER sur cette instance + { + CBotVarClass* instance = new CBotVarClass(&name, type); + CBotVarPointer* pointer = new CBotVarPointer(&name, type); + pointer->SetPointer( instance ); +// pointer->SetClass( type.GivClass() ); + return pointer; + } + + case CBotTypArrayPointer: + return new CBotVarArray(&name, type); + + case CBotTypArrayBody: + { + CBotVarClass* instance = new CBotVarClass(&name, type); + CBotVarArray* array = new CBotVarArray(&name, type); + array->SetPointer( instance ); + + CBotVar* pv = array; + while (type.Eq(CBotTypArrayBody)) + { + type = type.GivTypElem(); + pv = ((CBotVarArray*)pv)->GivItem(0, true); // crée au moins l'élément [0] + } + + return array; + } + } + + ASM_TRAP(); + return NULL; } CBotVar* CBotVar::Create( const char* name, int type, CBotClass* pClass) { - CBotToken token( name, "" ); - CBotVar* pVar = Create( &token, type ); - - if ( type == CBotTypPointer && pClass == NULL ) // pointeur "null" ? - return pVar; - - if ( type == CBotTypClass || type == CBotTypPointer || - type == CBotTypIntrinsic ) - { - if (pClass == NULL) - { - delete pVar; - return NULL; - } - pVar->SetClass( pClass ); - } - return pVar; + CBotToken token( name, "" ); + CBotVar* pVar = Create( &token, type ); + + if ( type == CBotTypPointer && pClass == NULL ) // pointeur "null" ? + return pVar; + + if ( type == CBotTypClass || type == CBotTypPointer || + type == CBotTypIntrinsic ) + { + if (pClass == NULL) + { + delete pVar; + return NULL; + } + pVar->SetClass( pClass ); + } + return pVar; } CBotVar* CBotVar::Create( const char* name, CBotClass* pClass) { - CBotToken token( name, "" ); - CBotVar* pVar = Create( &token, CBotTypResult( CBotTypClass, pClass ) ); -// pVar->SetClass( pClass ); - return pVar; + CBotToken token( name, "" ); + CBotVar* pVar = Create( &token, CBotTypResult( CBotTypClass, pClass ) ); +// pVar->SetClass( pClass ); + return pVar; } CBotTypResult CBotVar::GivTypResult(int mode) { - CBotTypResult r = m_type; + CBotTypResult r = m_type; - if ( mode == 1 && m_type.Eq(CBotTypClass) ) - r.SetType(CBotTypPointer); - if ( mode == 2 && m_type.Eq(CBotTypClass) ) - r.SetType(CBotTypIntrinsic); + if ( mode == 1 && m_type.Eq(CBotTypClass) ) + r.SetType(CBotTypPointer); + if ( mode == 2 && m_type.Eq(CBotTypClass) ) + r.SetType(CBotTypIntrinsic); - return r; + return r; } int CBotVar::GivType(int mode) { - if ( mode == 1 && m_type.Eq(CBotTypClass) ) - return CBotTypPointer; - if ( mode == 2 && m_type.Eq(CBotTypClass) ) - return CBotTypIntrinsic; - return m_type.GivType(); + if ( mode == 1 && m_type.Eq(CBotTypClass) ) + return CBotTypPointer; + if ( mode == 2 && m_type.Eq(CBotTypClass) ) + return CBotTypIntrinsic; + return m_type.GivType(); } void CBotVar::SetType(CBotTypResult& type) { - m_type = type; + m_type = type; } int CBotVar::GivInit() { - if ( m_type.Eq(CBotTypClass) ) return IS_DEF; // toujours défini ! + if ( m_type.Eq(CBotTypClass) ) return IS_DEF; // toujours défini ! - return m_binit; + return m_binit; } void CBotVar::SetInit(int bInit) { - m_binit = bInit; - if ( bInit == 2 ) m_binit = IS_DEF; // cas spécial - - if ( m_type.Eq(CBotTypPointer) && bInit == 2 ) - { - CBotVarClass* instance = GivPointer(); - if ( instance == NULL ) - { - instance = new CBotVarClass(NULL, m_type); -// instance->SetClass(((CBotVarPointer*)this)->m_pClass); - SetPointer(instance); - } - instance->SetInit(1); - } - - if ( m_type.Eq(CBotTypClass) || m_type.Eq(CBotTypIntrinsic) ) - { - CBotVar* p = ((CBotVarClass*)this)->m_pVar; - while( p != NULL ) - { - p->SetInit( bInit ); - p->m_pMyThis = (CBotVarClass*)this; - p = p->GivNext(); - } - } + m_binit = bInit; + if ( bInit == 2 ) m_binit = IS_DEF; // cas spécial + + if ( m_type.Eq(CBotTypPointer) && bInit == 2 ) + { + CBotVarClass* instance = GivPointer(); + if ( instance == NULL ) + { + instance = new CBotVarClass(NULL, m_type); +// instance->SetClass(((CBotVarPointer*)this)->m_pClass); + SetPointer(instance); + } + instance->SetInit(1); + } + + if ( m_type.Eq(CBotTypClass) || m_type.Eq(CBotTypIntrinsic) ) + { + CBotVar* p = ((CBotVarClass*)this)->m_pVar; + while( p != NULL ) + { + p->SetInit( bInit ); + p->m_pMyThis = (CBotVarClass*)this; + p = p->GivNext(); + } + } } CBotString CBotVar::GivName() { - return m_token->GivString(); + return m_token->GivString(); } void CBotVar::SetName(const char* name) { - m_token->SetString(name); + m_token->SetString(name); } CBotToken* CBotVar::GivToken() { - return m_token; + return m_token; } CBotVar* CBotVar::GivItem(const char* name) { - ASM_TRAP(); - return NULL; + ASM_TRAP(); + return NULL; } CBotVar* CBotVar::GivItemRef(int nIdent) { - ASM_TRAP(); - return NULL; + ASM_TRAP(); + return NULL; } CBotVar* CBotVar::GivItemList() { - ASM_TRAP(); - return NULL; + ASM_TRAP(); + return NULL; } CBotVar* CBotVar::GivItem(int row, bool bGrow) { - ASM_TRAP(); - return NULL; + ASM_TRAP(); + return NULL; } // dit si une variable appartient à une classe donnée bool CBotVar::IsElemOfClass(const char* name) { - CBotClass* pc = NULL; + CBotClass* pc = NULL; - if ( m_type.Eq(CBotTypPointer) ) - { - pc = ((CBotVarPointer*)this)->m_pClass; - } - if ( m_type.Eq(CBotTypClass) ) - { - pc = ((CBotVarClass*)this)->m_pClass; - } + if ( m_type.Eq(CBotTypPointer) ) + { + pc = ((CBotVarPointer*)this)->m_pClass; + } + if ( m_type.Eq(CBotTypClass) ) + { + pc = ((CBotVarClass*)this)->m_pClass; + } - while ( pc != NULL ) - { - if ( pc->GivName() == name ) return true; - pc = pc->GivParent(); - } + while ( pc != NULL ) + { + if ( pc->GivName() == name ) return true; + pc = pc->GivParent(); + } - return false; + return false; } CBotVar* CBotVar::GivStaticVar() { - // rend le pointeur à la variable si elle est statique - if ( m_bStatic == 0 || m_pMyThis == NULL ) return this; + // rend le pointeur à la variable si elle est statique + if ( m_bStatic == 0 || m_pMyThis == NULL ) return this; - CBotClass* pClass = m_pMyThis->GivClass(); - return pClass->GivItem( m_token->GivString() ); + CBotClass* pClass = m_pMyThis->GivClass(); + return pClass->GivItem( m_token->GivString() ); } CBotVar* CBotVar::GivNext() { - return m_next; + return m_next; } void CBotVar::AddNext(CBotVar* pVar) { - CBotVar* p = this; - while (p->m_next != NULL) p = p->m_next; + CBotVar* p = this; + while (p->m_next != NULL) p = p->m_next; - p->m_next = pVar; + p->m_next = pVar; } void CBotVar::SetVal(CBotVar* var) { - switch (/*var->*/GivType()) - { - case CBotTypBoolean: - SetValInt(var->GivValInt()); - break; - case CBotTypInt: - SetValInt(var->GivValInt(), ((CBotVarInt*)var)->m_defnum); - break; - case CBotTypFloat: - SetValFloat(var->GivValFloat()); - break; - case CBotTypString: - SetValString(var->GivValString()); - break; - case CBotTypPointer: - case CBotTypNullPointer: - case CBotTypArrayPointer: - SetPointer(var->GivPointer()); - break; - case CBotTypClass: - { - delete ((CBotVarClass*)this)->m_pVar; - ((CBotVarClass*)this)->m_pVar = NULL; - Copy(var, false); - } - break; - default: - ASM_TRAP(); - } - - m_binit = var->m_binit; // copie l'état nan s'il y a + switch (/*var->*/GivType()) + { + case CBotTypBoolean: + SetValInt(var->GivValInt()); + break; + case CBotTypInt: + SetValInt(var->GivValInt(), ((CBotVarInt*)var)->m_defnum); + break; + case CBotTypFloat: + SetValFloat(var->GivValFloat()); + break; + case CBotTypString: + SetValString(var->GivValString()); + break; + case CBotTypPointer: + case CBotTypNullPointer: + case CBotTypArrayPointer: + SetPointer(var->GivPointer()); + break; + case CBotTypClass: + { + delete ((CBotVarClass*)this)->m_pVar; + ((CBotVarClass*)this)->m_pVar = NULL; + Copy(var, false); + } + break; + default: + ASM_TRAP(); + } + + m_binit = var->m_binit; // copie l'état nan s'il y a } void CBotVar::SetStatic(bool bStatic) { - m_bStatic = bStatic; + m_bStatic = bStatic; } void CBotVar::SetPrivate(int mPrivate) { - m_mPrivate = mPrivate; + m_mPrivate = mPrivate; } bool CBotVar::IsStatic() { - return m_bStatic; + return m_bStatic; } bool CBotVar::IsPrivate(int mode) { - return m_mPrivate >= mode; + return m_mPrivate >= mode; } int CBotVar::GivPrivate() { - return m_mPrivate; + return m_mPrivate; } void CBotVar::SetPointer(CBotVar* pVarClass) { - ASM_TRAP(); + ASM_TRAP(); } CBotVarClass* CBotVar::GivPointer() { - ASM_TRAP(); - return NULL; + ASM_TRAP(); + return NULL; } // toutes ces fonctions doivent être définies dans les classes filles @@ -663,174 +663,174 @@ CBotVarClass* CBotVar::GivPointer() int CBotVar::GivValInt() { - ASM_TRAP(); - return 0; + ASM_TRAP(); + return 0; } float CBotVar::GivValFloat() { - ASM_TRAP(); - return 0; + ASM_TRAP(); + return 0; } void CBotVar::SetValInt(int c, const char* s) { - ASM_TRAP(); + ASM_TRAP(); } void CBotVar::SetValFloat(float c) { - ASM_TRAP(); + ASM_TRAP(); } void CBotVar::Mul(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + ASM_TRAP(); } void CBotVar::Power(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + ASM_TRAP(); } int CBotVar::Div(CBotVar* left, CBotVar* right) { - ASM_TRAP(); - return 0; + ASM_TRAP(); + return 0; } int CBotVar::Modulo(CBotVar* left, CBotVar* right) { - ASM_TRAP(); - return 0; + ASM_TRAP(); + return 0; } void CBotVar::Add(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + ASM_TRAP(); } void CBotVar::Sub(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + ASM_TRAP(); } bool CBotVar::Lo(CBotVar* left, CBotVar* right) { - ASM_TRAP(); - return false; + ASM_TRAP(); + return false; } bool CBotVar::Hi(CBotVar* left, CBotVar* right) { - ASM_TRAP(); - return false; + ASM_TRAP(); + return false; } bool CBotVar::Ls(CBotVar* left, CBotVar* right) { - ASM_TRAP(); - return false; + ASM_TRAP(); + return false; } bool CBotVar::Hs(CBotVar* left, CBotVar* right) { - ASM_TRAP(); - return false; + ASM_TRAP(); + return false; } bool CBotVar::Eq(CBotVar* left, CBotVar* right) { - ASM_TRAP(); - return false; + ASM_TRAP(); + return false; } bool CBotVar::Ne(CBotVar* left, CBotVar* right) { - ASM_TRAP(); - return false; + ASM_TRAP(); + return false; } void CBotVar::And(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + ASM_TRAP(); } void CBotVar::Or(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + ASM_TRAP(); } void CBotVar::XOr(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + ASM_TRAP(); } void CBotVar::ASR(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + ASM_TRAP(); } void CBotVar::SR(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + ASM_TRAP(); } void CBotVar::SL(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + ASM_TRAP(); } void CBotVar::Neg() { - ASM_TRAP(); + ASM_TRAP(); } void CBotVar::Not() { - ASM_TRAP(); + ASM_TRAP(); } void CBotVar::Inc() { - ASM_TRAP(); + ASM_TRAP(); } void CBotVar::Dec() { - ASM_TRAP(); + ASM_TRAP(); } void CBotVar::Copy(CBotVar* pSrc, bool bName) { - ASM_TRAP(); + ASM_TRAP(); } void CBotVar::SetValString(const char* p) { - ASM_TRAP(); + ASM_TRAP(); } CBotString CBotVar::GivValString() { - ASM_TRAP(); - return CBotString(); + ASM_TRAP(); + return CBotString(); } void CBotVar::SetClass(CBotClass* pClass) { - ASM_TRAP(); + ASM_TRAP(); } CBotClass* CBotVar::GivClass() { - ASM_TRAP(); - return NULL; + ASM_TRAP(); + return NULL; } /* void CBotVar::SetIndirection(CBotVar* pVar) { - // nop, uniquement pour CBotVarPointer::SetIndirection + // nop, uniquement pour CBotVarPointer::SetIndirection } */ @@ -839,19 +839,19 @@ void CBotVar::SetIndirection(CBotVar* pVar) // copie une variable dans une autre void CBotVarInt::Copy(CBotVar* pSrc, bool bName) { - CBotVarInt* p = (CBotVarInt*)pSrc; + CBotVarInt* p = (CBotVarInt*)pSrc; - if ( bName) *m_token = *p->m_token; - m_type = p->m_type; - m_val = p->m_val; - m_binit = p->m_binit; - m_pMyThis = NULL; - m_pUserPtr = p->m_pUserPtr; + if ( bName) *m_token = *p->m_token; + m_type = p->m_type; + m_val = p->m_val; + m_binit = p->m_binit; + m_pMyThis = NULL; + m_pUserPtr = p->m_pUserPtr; - // garde le même idendificateur (par défaut) - if (m_ident == 0 ) m_ident = p->m_ident; + // garde le même idendificateur (par défaut) + if (m_ident == 0 ) m_ident = p->m_ident; - m_defnum = p->m_defnum; + m_defnum = p->m_defnum; } @@ -859,189 +859,189 @@ void CBotVarInt::Copy(CBotVar* pSrc, bool bName) void CBotVarInt::SetValInt(int val, const char* defnum) { - m_val = val; - m_binit = true; - m_defnum = defnum; + m_val = val; + m_binit = true; + m_defnum = defnum; } void CBotVarInt::SetValFloat(float val) { - m_val = (int)val; - m_binit = true; + m_val = (int)val; + m_binit = true; } int CBotVarInt::GivValInt() { - return m_val; + return m_val; } float CBotVarInt::GivValFloat() { - return (float)m_val; + return (float)m_val; } CBotString CBotVarInt::GivValString() { - if ( !m_defnum.IsEmpty() ) return m_defnum; + if ( !m_defnum.IsEmpty() ) return m_defnum; - CBotString res; + CBotString res; - if ( !m_binit ) - { - res.LoadString(TX_UNDEF); - return res; - } - if ( m_binit == IS_NAN ) - { - res.LoadString(TX_NAN); - return res; - } + if ( !m_binit ) + { + res.LoadString(TX_UNDEF); + return res; + } + if ( m_binit == IS_NAN ) + { + res.LoadString(TX_NAN); + return res; + } - char buffer[300]; - sprintf(buffer, "%d", m_val); - res = buffer; + char buffer[300]; + sprintf(buffer, "%d", m_val); + res = buffer; - return res; + return res; } void CBotVarInt::Mul(CBotVar* left, CBotVar* right) { - m_val = left->GivValInt() * right->GivValInt(); - m_binit = true; + m_val = left->GivValInt() * right->GivValInt(); + m_binit = true; } void CBotVarInt::Power(CBotVar* left, CBotVar* right) { - m_val = (int) pow( (double) left->GivValInt() , (double) right->GivValInt() ); - m_binit = true; + m_val = (int) pow( (double) left->GivValInt() , (double) right->GivValInt() ); + m_binit = true; } int CBotVarInt::Div(CBotVar* left, CBotVar* right) { - int r = right->GivValInt(); - if ( r != 0 ) - { - m_val = left->GivValInt() / r; - m_binit = true; - } - return ( r == 0 ? TX_DIVZERO : 0 ); + int r = right->GivValInt(); + if ( r != 0 ) + { + m_val = left->GivValInt() / r; + m_binit = true; + } + return ( r == 0 ? TX_DIVZERO : 0 ); } int CBotVarInt::Modulo(CBotVar* left, CBotVar* right) { - int r = right->GivValInt(); - if ( r != 0 ) - { - m_val = left->GivValInt() % r; - m_binit = true; - } - return ( r == 0 ? TX_DIVZERO : 0 ); + int r = right->GivValInt(); + if ( r != 0 ) + { + m_val = left->GivValInt() % r; + m_binit = true; + } + return ( r == 0 ? TX_DIVZERO : 0 ); } void CBotVarInt::Add(CBotVar* left, CBotVar* right) { - m_val = left->GivValInt() + right->GivValInt(); - m_binit = true; + m_val = left->GivValInt() + right->GivValInt(); + m_binit = true; } void CBotVarInt::Sub(CBotVar* left, CBotVar* right) { - m_val = left->GivValInt() - right->GivValInt(); - m_binit = true; + m_val = left->GivValInt() - right->GivValInt(); + m_binit = true; } void CBotVarInt::XOr(CBotVar* left, CBotVar* right) { - m_val = left->GivValInt() ^ right->GivValInt(); - m_binit = true; + m_val = left->GivValInt() ^ right->GivValInt(); + m_binit = true; } void CBotVarInt::And(CBotVar* left, CBotVar* right) { - m_val = left->GivValInt() & right->GivValInt(); - m_binit = true; + m_val = left->GivValInt() & right->GivValInt(); + m_binit = true; } void CBotVarInt::Or(CBotVar* left, CBotVar* right) { - m_val = left->GivValInt() | right->GivValInt(); - m_binit = true; + m_val = left->GivValInt() | right->GivValInt(); + m_binit = true; } void CBotVarInt::SL(CBotVar* left, CBotVar* right) { - m_val = left->GivValInt() << right->GivValInt(); - m_binit = true; + m_val = left->GivValInt() << right->GivValInt(); + m_binit = true; } void CBotVarInt::ASR(CBotVar* left, CBotVar* right) { - m_val = left->GivValInt() >> right->GivValInt(); - m_binit = true; + m_val = left->GivValInt() >> right->GivValInt(); + m_binit = true; } void CBotVarInt::SR(CBotVar* left, CBotVar* right) { - int source = left->GivValInt(); - int shift = right->GivValInt(); - if (shift>=1) source &= 0x7fffffff; - m_val = source >> shift; - m_binit = true; + int source = left->GivValInt(); + int shift = right->GivValInt(); + if (shift>=1) source &= 0x7fffffff; + m_val = source >> shift; + m_binit = true; } void CBotVarInt::Neg() { - m_val = -m_val; + m_val = -m_val; } void CBotVarInt::Not() { - m_val = ~m_val; + m_val = ~m_val; } void CBotVarInt::Inc() { - m_val++; - m_defnum.Empty(); + m_val++; + m_defnum.Empty(); } void CBotVarInt::Dec() { - m_val--; - m_defnum.Empty(); + m_val--; + m_defnum.Empty(); } bool CBotVarInt::Lo(CBotVar* left, CBotVar* right) { - return left->GivValInt() < right->GivValInt(); + return left->GivValInt() < right->GivValInt(); } bool CBotVarInt::Hi(CBotVar* left, CBotVar* right) { - return left->GivValInt() > right->GivValInt(); + return left->GivValInt() > right->GivValInt(); } bool CBotVarInt::Ls(CBotVar* left, CBotVar* right) { - return left->GivValInt() <= right->GivValInt(); + return left->GivValInt() <= right->GivValInt(); } bool CBotVarInt::Hs(CBotVar* left, CBotVar* right) { - return left->GivValInt() >= right->GivValInt(); + return left->GivValInt() >= right->GivValInt(); } bool CBotVarInt::Eq(CBotVar* left, CBotVar* right) { - return left->GivValInt() == right->GivValInt(); + return left->GivValInt() == right->GivValInt(); } bool CBotVarInt::Ne(CBotVar* left, CBotVar* right) { - return left->GivValInt() != right->GivValInt(); + return left->GivValInt() != right->GivValInt(); } @@ -1050,19 +1050,19 @@ bool CBotVarInt::Ne(CBotVar* left, CBotVar* right) // copie une variable dans une autre void CBotVarFloat::Copy(CBotVar* pSrc, bool bName) { - CBotVarFloat* p = (CBotVarFloat*)pSrc; + CBotVarFloat* p = (CBotVarFloat*)pSrc; - if (bName) *m_token = *p->m_token; - m_type = p->m_type; - m_val = p->m_val; - m_binit = p->m_binit; -//- m_bStatic = p->m_bStatic; - m_next = NULL; - m_pMyThis = NULL;//p->m_pMyThis; - m_pUserPtr = p->m_pUserPtr; + if (bName) *m_token = *p->m_token; + m_type = p->m_type; + m_val = p->m_val; + m_binit = p->m_binit; +//- m_bStatic = p->m_bStatic; + m_next = NULL; + m_pMyThis = NULL;//p->m_pMyThis; + m_pUserPtr = p->m_pUserPtr; - // garde le même idendificateur (par défaut) - if (m_ident == 0 ) m_ident = p->m_ident; + // garde le même idendificateur (par défaut) + if (m_ident == 0 ) m_ident = p->m_ident; } @@ -1070,139 +1070,139 @@ void CBotVarFloat::Copy(CBotVar* pSrc, bool bName) void CBotVarFloat::SetValInt(int val, const char* s) { - m_val = (float)val; - m_binit = true; + m_val = (float)val; + m_binit = true; } void CBotVarFloat::SetValFloat(float val) { - m_val = val; - m_binit = true; + m_val = val; + m_binit = true; } int CBotVarFloat::GivValInt() { - return (int)m_val; + return (int)m_val; } float CBotVarFloat::GivValFloat() { - return m_val; + return m_val; } CBotString CBotVarFloat::GivValString() { - CBotString res; + CBotString res; - if ( !m_binit ) - { - res.LoadString(TX_UNDEF); - return res; - } - if ( m_binit == IS_NAN ) - { - res.LoadString(TX_NAN); - return res; - } + if ( !m_binit ) + { + res.LoadString(TX_UNDEF); + return res; + } + if ( m_binit == IS_NAN ) + { + res.LoadString(TX_NAN); + return res; + } - char buffer[300]; - sprintf(buffer, "%.2f", m_val); - res = buffer; + char buffer[300]; + sprintf(buffer, "%.2f", m_val); + res = buffer; - return res; + return res; } void CBotVarFloat::Mul(CBotVar* left, CBotVar* right) { - m_val = left->GivValFloat() * right->GivValFloat(); - m_binit = true; + m_val = left->GivValFloat() * right->GivValFloat(); + m_binit = true; } void CBotVarFloat::Power(CBotVar* left, CBotVar* right) { - m_val = (float)pow( left->GivValFloat() , right->GivValFloat() ); - m_binit = true; + m_val = (float)pow( left->GivValFloat() , right->GivValFloat() ); + m_binit = true; } int CBotVarFloat::Div(CBotVar* left, CBotVar* right) { - float r = right->GivValFloat(); - if ( r != 0 ) - { - m_val = left->GivValFloat() / r; - m_binit = true; - } - return ( r == 0 ? TX_DIVZERO : 0 ); + float r = right->GivValFloat(); + if ( r != 0 ) + { + m_val = left->GivValFloat() / r; + m_binit = true; + } + return ( r == 0 ? TX_DIVZERO : 0 ); } int CBotVarFloat::Modulo(CBotVar* left, CBotVar* right) { - float r = right->GivValFloat(); - if ( r != 0 ) - { - m_val = (float)fmod( left->GivValFloat() , r ); - m_binit = true; - } - return ( r == 0 ? TX_DIVZERO : 0 ); + float r = right->GivValFloat(); + if ( r != 0 ) + { + m_val = (float)fmod( left->GivValFloat() , r ); + m_binit = true; + } + return ( r == 0 ? TX_DIVZERO : 0 ); } void CBotVarFloat::Add(CBotVar* left, CBotVar* right) { - m_val = left->GivValFloat() + right->GivValFloat(); - m_binit = true; + m_val = left->GivValFloat() + right->GivValFloat(); + m_binit = true; } void CBotVarFloat::Sub(CBotVar* left, CBotVar* right) { - m_val = left->GivValFloat() - right->GivValFloat(); - m_binit = true; + m_val = left->GivValFloat() - right->GivValFloat(); + m_binit = true; } void CBotVarFloat::Neg() { - m_val = -m_val; + m_val = -m_val; } void CBotVarFloat::Inc() { - m_val++; + m_val++; } void CBotVarFloat::Dec() { - m_val--; + m_val--; } bool CBotVarFloat::Lo(CBotVar* left, CBotVar* right) { - return left->GivValFloat() < right->GivValFloat(); + return left->GivValFloat() < right->GivValFloat(); } bool CBotVarFloat::Hi(CBotVar* left, CBotVar* right) { - return left->GivValFloat() > right->GivValFloat(); + return left->GivValFloat() > right->GivValFloat(); } bool CBotVarFloat::Ls(CBotVar* left, CBotVar* right) { - return left->GivValFloat() <= right->GivValFloat(); + return left->GivValFloat() <= right->GivValFloat(); } bool CBotVarFloat::Hs(CBotVar* left, CBotVar* right) { - return left->GivValFloat() >= right->GivValFloat(); + return left->GivValFloat() >= right->GivValFloat(); } bool CBotVarFloat::Eq(CBotVar* left, CBotVar* right) { - return left->GivValFloat() == right->GivValFloat(); + return left->GivValFloat() == right->GivValFloat(); } bool CBotVarFloat::Ne(CBotVar* left, CBotVar* right) { - return left->GivValFloat() != right->GivValFloat(); + return left->GivValFloat() != right->GivValFloat(); } @@ -1211,19 +1211,19 @@ bool CBotVarFloat::Ne(CBotVar* left, CBotVar* right) // copie une variable dans une autre void CBotVarBoolean::Copy(CBotVar* pSrc, bool bName) { - CBotVarBoolean* p = (CBotVarBoolean*)pSrc; + CBotVarBoolean* p = (CBotVarBoolean*)pSrc; - if (bName) *m_token = *p->m_token; - m_type = p->m_type; - m_val = p->m_val; - m_binit = p->m_binit; -//- m_bStatic = p->m_bStatic; - m_next = NULL; - m_pMyThis = NULL;//p->m_pMyThis; - m_pUserPtr = p->m_pUserPtr; + if (bName) *m_token = *p->m_token; + m_type = p->m_type; + m_val = p->m_val; + m_binit = p->m_binit; +//- m_bStatic = p->m_bStatic; + m_next = NULL; + m_pMyThis = NULL;//p->m_pMyThis; + m_pUserPtr = p->m_pUserPtr; - // garde le même idendificateur (par défaut) - if (m_ident == 0 ) m_ident = p->m_ident; + // garde le même idendificateur (par défaut) + if (m_ident == 0 ) m_ident = p->m_ident; } @@ -1231,77 +1231,77 @@ void CBotVarBoolean::Copy(CBotVar* pSrc, bool bName) void CBotVarBoolean::SetValInt(int val, const char* s) { - m_val = (bool)val; - m_binit = true; + m_val = (bool)val; + m_binit = true; } void CBotVarBoolean::SetValFloat(float val) { - m_val = (bool)val; - m_binit = true; + m_val = (bool)val; + m_binit = true; } int CBotVarBoolean::GivValInt() { - return m_val; + return m_val; } float CBotVarBoolean::GivValFloat() { - return (float)m_val; + return (float)m_val; } CBotString CBotVarBoolean::GivValString() { - CBotString ret; + CBotString ret; - CBotString res; + CBotString res; - if ( !m_binit ) - { - res.LoadString(TX_UNDEF); - return res; - } - if ( m_binit == IS_NAN ) - { - res.LoadString(TX_NAN); - return res; - } + if ( !m_binit ) + { + res.LoadString(TX_UNDEF); + return res; + } + if ( m_binit == IS_NAN ) + { + res.LoadString(TX_NAN); + return res; + } - ret.LoadString( m_val > 0 ? ID_TRUE : ID_FALSE ); - return ret; + ret.LoadString( m_val > 0 ? ID_TRUE : ID_FALSE ); + return ret; } void CBotVarBoolean::And(CBotVar* left, CBotVar* right) { - m_val = left->GivValInt() && right->GivValInt(); - m_binit = true; + m_val = left->GivValInt() && right->GivValInt(); + m_binit = true; } void CBotVarBoolean::Or(CBotVar* left, CBotVar* right) { - m_val = left->GivValInt() || right->GivValInt(); - m_binit = true; + m_val = left->GivValInt() || right->GivValInt(); + m_binit = true; } void CBotVarBoolean::XOr(CBotVar* left, CBotVar* right) { - m_val = left->GivValInt() ^ right->GivValInt(); - m_binit = true; + m_val = left->GivValInt() ^ right->GivValInt(); + m_binit = true; } void CBotVarBoolean::Not() { - m_val = m_val ? false : true ; + m_val = m_val ? false : true ; } bool CBotVarBoolean::Eq(CBotVar* left, CBotVar* right) { - return left->GivValInt() == right->GivValInt(); + return left->GivValInt() == right->GivValInt(); } bool CBotVarBoolean::Ne(CBotVar* left, CBotVar* right) { - return left->GivValInt() != right->GivValInt(); + return left->GivValInt() != right->GivValInt(); } ////////////////////////////////////////////////////////////////////////////////////// @@ -1309,82 +1309,82 @@ bool CBotVarBoolean::Ne(CBotVar* left, CBotVar* right) // copie une variable dans une autre void CBotVarString::Copy(CBotVar* pSrc, bool bName) { - CBotVarString* p = (CBotVarString*)pSrc; + CBotVarString* p = (CBotVarString*)pSrc; - if (bName) *m_token = *p->m_token; - m_type = p->m_type; - m_val = p->m_val; - m_binit = p->m_binit; -//- m_bStatic = p->m_bStatic; - m_next = NULL; - m_pMyThis = NULL;//p->m_pMyThis; - m_pUserPtr = p->m_pUserPtr; + if (bName) *m_token = *p->m_token; + m_type = p->m_type; + m_val = p->m_val; + m_binit = p->m_binit; +//- m_bStatic = p->m_bStatic; + m_next = NULL; + m_pMyThis = NULL;//p->m_pMyThis; + m_pUserPtr = p->m_pUserPtr; - // garde le même idendificateur (par défaut) - if (m_ident == 0 ) m_ident = p->m_ident; + // garde le même idendificateur (par défaut) + if (m_ident == 0 ) m_ident = p->m_ident; } void CBotVarString::SetValString(const char* p) { - m_val = p; - m_binit = true; + m_val = p; + m_binit = true; } CBotString CBotVarString::GivValString() { - if ( !m_binit ) - { - CBotString res; - res.LoadString(TX_UNDEF); - return res; - } - if ( m_binit == IS_NAN ) - { - CBotString res; - res.LoadString(TX_NAN); - return res; - } + if ( !m_binit ) + { + CBotString res; + res.LoadString(TX_UNDEF); + return res; + } + if ( m_binit == IS_NAN ) + { + CBotString res; + res.LoadString(TX_NAN); + return res; + } - return m_val; + return m_val; } void CBotVarString::Add(CBotVar* left, CBotVar* right) { - m_val = left->GivValString() + right->GivValString(); - m_binit = true; + m_val = left->GivValString() + right->GivValString(); + m_binit = true; } bool CBotVarString::Eq(CBotVar* left, CBotVar* right) { - return (left->GivValString() == right->GivValString()); + return (left->GivValString() == right->GivValString()); } bool CBotVarString::Ne(CBotVar* left, CBotVar* right) { - return (left->GivValString() != right->GivValString()); + return (left->GivValString() != right->GivValString()); } bool CBotVarString::Lo(CBotVar* left, CBotVar* right) { - return (left->GivValString() == right->GivValString()); + return (left->GivValString() == right->GivValString()); } bool CBotVarString::Hi(CBotVar* left, CBotVar* right) { - return (left->GivValString() == right->GivValString()); + return (left->GivValString() == right->GivValString()); } bool CBotVarString::Ls(CBotVar* left, CBotVar* right) { - return (left->GivValString() == right->GivValString()); + return (left->GivValString() == right->GivValString()); } bool CBotVarString::Hs(CBotVar* left, CBotVar* right) { - return (left->GivValString() == right->GivValString()); + return (left->GivValString() == right->GivValString()); } @@ -1393,177 +1393,177 @@ bool CBotVarString::Hs(CBotVar* left, CBotVar* right) // copie une variable dans une autre void CBotVarClass::Copy(CBotVar* pSrc, bool bName) { - pSrc = pSrc->GivPointer(); // si source donné par un pointeur + pSrc = pSrc->GivPointer(); // si source donné par un pointeur - if ( pSrc->GivType() != CBotTypClass ) - ASM_TRAP(); + if ( pSrc->GivType() != CBotTypClass ) + ASM_TRAP(); - CBotVarClass* p = (CBotVarClass*)pSrc; + CBotVarClass* p = (CBotVarClass*)pSrc; - if (bName) *m_token = *p->m_token; + if (bName) *m_token = *p->m_token; - m_type = p->m_type; - m_binit = p->m_binit; -//- m_bStatic = p->m_bStatic; - m_pClass = p->m_pClass; - if ( p->m_pParent ) - { - ASM_TRAP(); "que faire du pParent"; - } + m_type = p->m_type; + m_binit = p->m_binit; +//- m_bStatic = p->m_bStatic; + m_pClass = p->m_pClass; + if ( p->m_pParent ) + { + ASM_TRAP(); "que faire du pParent"; + } -// m_next = NULL; - m_pUserPtr = p->m_pUserPtr; - m_pMyThis = NULL;//p->m_pMyThis; - m_ItemIdent = p->m_ItemIdent; +// m_next = NULL; + m_pUserPtr = p->m_pUserPtr; + m_pMyThis = NULL;//p->m_pMyThis; + m_ItemIdent = p->m_ItemIdent; - // garde le même idendificateur (par défaut) - if (m_ident == 0 ) m_ident = p->m_ident; + // garde le même idendificateur (par défaut) + if (m_ident == 0 ) m_ident = p->m_ident; - delete m_pVar; - m_pVar = NULL; + delete m_pVar; + m_pVar = NULL; - CBotVar* pv = p->m_pVar; - while( pv != NULL ) - { - CBotVar* pn = CBotVar::Create(pv); - pn->Copy( pv ); - if ( m_pVar == NULL ) m_pVar = pn; - else m_pVar->AddNext(pn); + CBotVar* pv = p->m_pVar; + while( pv != NULL ) + { + CBotVar* pn = CBotVar::Create(pv); + pn->Copy( pv ); + if ( m_pVar == NULL ) m_pVar = pn; + else m_pVar->AddNext(pn); - pv = pv->GivNext(); - } + pv = pv->GivNext(); + } } void CBotVarClass::SetItemList(CBotVar* pVar) { - delete m_pVar; - m_pVar = pVar; // remplace le pointeur existant + delete m_pVar; + m_pVar = pVar; // remplace le pointeur existant } void CBotVarClass::SetIdent(long n) { - m_ItemIdent = n; + m_ItemIdent = n; } void CBotVarClass::SetClass(CBotClass* pClass)//, int &nIdent) { - m_type.m_pClass = pClass; + m_type.m_pClass = pClass; - if ( m_pClass == pClass ) return; + if ( m_pClass == pClass ) return; - m_pClass = pClass; + m_pClass = pClass; - // initialise les variables associées à cette classe - delete m_pVar; - m_pVar = NULL; + // initialise les variables associées à cette classe + delete m_pVar; + m_pVar = NULL; - if (pClass == NULL) return; + if (pClass == NULL) return; - CBotVar* pv = pClass->GivVar(); // premier de la liste - while ( pv != NULL ) - { - // cherche les dimensions max du tableau - CBotInstr* p = pv->m_LimExpr; // les différentes formules - if ( p != NULL ) - { - CBotStack* pile = CBotStack::FirstStack(); // une pile indépendante - int n = 0; - int max[100]; + CBotVar* pv = pClass->GivVar(); // premier de la liste + while ( pv != NULL ) + { + // cherche les dimensions max du tableau + CBotInstr* p = pv->m_LimExpr; // les différentes formules + if ( p != NULL ) + { + CBotStack* pile = CBotStack::FirstStack(); // une pile indépendante + int n = 0; + int max[100]; - while (p != NULL) - { - while( pile->IsOk() && !p->Execute(pile) ) ; // calcul de la taille sans interruptions - CBotVar* v = pile->GivVar(); // résultat - max[n] = v->GivValInt(); // valeur - n++; - p = p->GivNext3(); - } - while (n<100) max[n++] = 0; + while (p != NULL) + { + while( pile->IsOk() && !p->Execute(pile) ) ; // calcul de la taille sans interruptions + CBotVar* v = pile->GivVar(); // résultat + max[n] = v->GivValInt(); // valeur + n++; + p = p->GivNext3(); + } + while (n<100) max[n++] = 0; - pv->m_type.SetArray( max ); // mémorise les limitations - pile->Delete(); - } + pv->m_type.SetArray( max ); // mémorise les limitations + pile->Delete(); + } - CBotVar* pn = CBotVar::Create( pv ); // une copie - pn->SetStatic(pv->IsStatic()); - pn->SetPrivate(pv->GivPrivate()); + CBotVar* pn = CBotVar::Create( pv ); // une copie + pn->SetStatic(pv->IsStatic()); + pn->SetPrivate(pv->GivPrivate()); - if ( pv->m_InitExpr != NULL ) // expression pour l'initialisation ? - { -#if STACKMEM - CBotStack* pile = CBotStack::FirstStack(); // une pile indépendante + if ( pv->m_InitExpr != NULL ) // expression pour l'initialisation ? + { +#if STACKMEM + CBotStack* pile = CBotStack::FirstStack(); // une pile indépendante - while(pile->IsOk() && !pv->m_InitExpr->Execute(pile, pn)); // évalue l'expression sans timer + while(pile->IsOk() && !pv->m_InitExpr->Execute(pile, pn)); // évalue l'expression sans timer - pile->Delete(); + pile->Delete(); #else - CBotStack* pile = new CBotStack(NULL); // une pile indépendante - while(!pv->m_InitExpr->Execute(pile)); // évalue l'expression sans timer - pn->SetVal( pile->GivVar() ) ; - delete pile; + CBotStack* pile = new CBotStack(NULL); // une pile indépendante + while(!pv->m_InitExpr->Execute(pile)); // évalue l'expression sans timer + pn->SetVal( pile->GivVar() ) ; + delete pile; #endif - } + } -// pn->SetUniqNum(CBotVar::NextUniqNum()); // numérote les éléments - pn->SetUniqNum(pv->GivUniqNum()); //++nIdent - pn->m_pMyThis = this; +// pn->SetUniqNum(CBotVar::NextUniqNum()); // numérote les éléments + pn->SetUniqNum(pv->GivUniqNum()); //++nIdent + pn->m_pMyThis = this; - if ( m_pVar == NULL) m_pVar = pn; - else m_pVar->AddNext( pn ); - pv = pv->GivNext(); - } + if ( m_pVar == NULL) m_pVar = pn; + else m_pVar->AddNext( pn ); + pv = pv->GivNext(); + } } CBotClass* CBotVarClass::GivClass() { - return m_pClass; + return m_pClass; } void CBotVarClass::Maj(void* pUser, bool bContinu) { -/* if (!bContinu && m_pMyThis != NULL) - m_pMyThis->Maj(pUser, true);*/ +/* if (!bContinu && m_pMyThis != NULL) + m_pMyThis->Maj(pUser, true);*/ - // une routine de mise à jour existe-elle ? + // une routine de mise à jour existe-elle ? - if ( m_pClass->m_rMaj == NULL ) return; + if ( m_pClass->m_rMaj == NULL ) return; - // récupère le pointeur user selon la classe - // ou selon le paramètre passé au CBotProgram::Run() + // récupère le pointeur user selon la classe + // ou selon le paramètre passé au CBotProgram::Run() - if ( m_pUserPtr != NULL) pUser = m_pUserPtr; - if ( pUser == OBJECTDELETED || - pUser == OBJECTCREATED ) return; - m_pClass->m_rMaj( this, pUser ); + if ( m_pUserPtr != NULL) pUser = m_pUserPtr; + if ( pUser == OBJECTDELETED || + pUser == OBJECTCREATED ) return; + m_pClass->m_rMaj( this, pUser ); } CBotVar* CBotVarClass::GivItem(const char* name) { - CBotVar* p = m_pVar; + CBotVar* p = m_pVar; - while ( p != NULL ) - { - if ( p->GivName() == name ) return p; - p = p->GivNext(); - } + while ( p != NULL ) + { + if ( p->GivName() == name ) return p; + p = p->GivNext(); + } - if ( m_pParent != NULL ) return m_pParent->GivItem(name); - return NULL; + if ( m_pParent != NULL ) return m_pParent->GivItem(name); + return NULL; } CBotVar* CBotVarClass::GivItemRef(int nIdent) { - CBotVar* p = m_pVar; + CBotVar* p = m_pVar; - while ( p != NULL ) - { - if ( p->GivUniqNum() == nIdent ) return p; - p = p->GivNext(); - } + while ( p != NULL ) + { + if ( p->GivUniqNum() == nIdent ) return p; + p = p->GivNext(); + } - if ( m_pParent != NULL ) return m_pParent->GivItemRef(nIdent); - return NULL; + if ( m_pParent != NULL ) return m_pParent->GivItemRef(nIdent); + return NULL; } // pour la gestion d'un tableau @@ -1571,145 +1571,145 @@ CBotVar* CBotVarClass::GivItemRef(int nIdent) CBotVar* CBotVarClass::GivItem(int n, bool bExtend) { - CBotVar* p = m_pVar; + CBotVar* p = m_pVar; - if ( n < 0 ) return NULL; - if ( n > MAXARRAYSIZE ) return NULL; + if ( n < 0 ) return NULL; + if ( n > MAXARRAYSIZE ) return NULL; - if ( m_type.GivLimite() >= 0 && n >= m_type.GivLimite() ) return NULL; + if ( m_type.GivLimite() >= 0 && n >= m_type.GivLimite() ) return NULL; - if ( p == NULL && bExtend ) - { - p = CBotVar::Create("", m_type.GivTypElem()); - m_pVar = p; - } + if ( p == NULL && bExtend ) + { + p = CBotVar::Create("", m_type.GivTypElem()); + m_pVar = p; + } - if ( n == 0 ) return p; + if ( n == 0 ) return p; - while ( n-- > 0 ) - { - if ( p->m_next == NULL ) - { - if ( bExtend ) p->m_next = CBotVar::Create("", m_type.GivTypElem()); - if ( p->m_next == NULL ) return NULL; - } - p = p->m_next; - } + while ( n-- > 0 ) + { + if ( p->m_next == NULL ) + { + if ( bExtend ) p->m_next = CBotVar::Create("", m_type.GivTypElem()); + if ( p->m_next == NULL ) return NULL; + } + p = p->m_next; + } - return p; + return p; } CBotVar* CBotVarClass::GivItemList() { - return m_pVar; + return m_pVar; } CBotString CBotVarClass::GivValString() { -// if ( m_Indirect != NULL) return m_Indirect->GivValString(); - - CBotString res; - - if ( m_pClass != NULL ) // pas utilisé pour un array - { - res = m_pClass->GivName() + CBotString("( "); - - CBotVarClass* my = this; - while ( my != NULL ) - { - CBotVar* pv = my->m_pVar; - while ( pv != NULL ) - { - res += pv->GivName() + CBotString("="); - - if ( pv->IsStatic() ) - { - CBotVar* pvv = my->m_pClass->GivItem(pv->GivName()); - res += pvv->GivValString(); - } - else - { - res += pv->GivValString(); - } - pv = pv->GivNext(); - if ( pv != NULL ) res += ", "; - } - my = my->m_pParent; - if ( my != NULL ) - { - res += ") extends "; - res += my->m_pClass->GivName(); - res += " ("; - } - } - } - else - { - res = "( "; - - CBotVar* pv = m_pVar; - while ( pv != NULL ) - { - res += pv->GivValString(); - if ( pv->GivNext() != NULL ) res += ", "; - pv = pv->GivNext(); - } - } - - res += " )"; - return res; +// if ( m_Indirect != NULL) return m_Indirect->GivValString(); + + CBotString res; + + if ( m_pClass != NULL ) // pas utilisé pour un array + { + res = m_pClass->GivName() + CBotString("( "); + + CBotVarClass* my = this; + while ( my != NULL ) + { + CBotVar* pv = my->m_pVar; + while ( pv != NULL ) + { + res += pv->GivName() + CBotString("="); + + if ( pv->IsStatic() ) + { + CBotVar* pvv = my->m_pClass->GivItem(pv->GivName()); + res += pvv->GivValString(); + } + else + { + res += pv->GivValString(); + } + pv = pv->GivNext(); + if ( pv != NULL ) res += ", "; + } + my = my->m_pParent; + if ( my != NULL ) + { + res += ") extends "; + res += my->m_pClass->GivName(); + res += " ("; + } + } + } + else + { + res = "( "; + + CBotVar* pv = m_pVar; + while ( pv != NULL ) + { + res += pv->GivValString(); + if ( pv->GivNext() != NULL ) res += ", "; + pv = pv->GivNext(); + } + } + + res += " )"; + return res; } void CBotVarClass::IncrementUse() { - m_CptUse++; + m_CptUse++; } void CBotVarClass::DecrementUse() { - m_CptUse--; - if ( m_CptUse == 0 ) - { - // s'il y en a un, appel le destructeur - // mais seulement si un constructeur avait été appelé. - if ( m_bConstructor ) - { - m_CptUse++; // ne revient pas dans le destructeur + m_CptUse--; + if ( m_CptUse == 0 ) + { + // s'il y en a un, appel le destructeur + // mais seulement si un constructeur avait été appelé. + if ( m_bConstructor ) + { + m_CptUse++; // ne revient pas dans le destructeur - // m_error est static dans le stack - // sauve la valeur pour la remettre ensuite - int err, start, end; - CBotStack* pile = NULL; - err = pile->GivError(start,end); // pile == NULL ça ne derange pas !! + // m_error est static dans le stack + // sauve la valeur pour la remettre ensuite + int err, start, end; + CBotStack* pile = NULL; + err = pile->GivError(start,end); // pile == NULL ça ne derange pas !! - pile = CBotStack::FirstStack(); // efface l'erreur - CBotVar* ppVars[1]; - ppVars[0] = NULL; + pile = CBotStack::FirstStack(); // efface l'erreur + CBotVar* ppVars[1]; + ppVars[0] = NULL; - CBotVar* pThis = CBotVar::Create("this", CBotTypNullPointer); - pThis->SetPointer(this); - CBotVar* pResult = NULL; + CBotVar* pThis = CBotVar::Create("this", CBotTypNullPointer); + pThis->SetPointer(this); + CBotVar* pResult = NULL; - CBotString nom = "~" + m_pClass->GivName(); - long ident = 0; + CBotString nom = "~" + m_pClass->GivName(); + long ident = 0; - while ( pile->IsOk() && !m_pClass->ExecuteMethode(ident, nom, pThis, ppVars, pResult, pile, NULL)) ; // attend la fin + while ( pile->IsOk() && !m_pClass->ExecuteMethode(ident, nom, pThis, ppVars, pResult, pile, NULL)) ; // attend la fin - pile->ResetError(err, start,end); + pile->ResetError(err, start,end); - pile->Delete(); - delete pThis; - m_CptUse--; - } + pile->Delete(); + delete pThis; + m_CptUse--; + } - delete this; // s'auto-détruit !! - } + delete this; // s'auto-détruit !! + } } CBotVarClass* CBotVarClass::GivPointer() { - return this; + return this; } @@ -1717,47 +1717,47 @@ CBotVarClass* CBotVarClass::GivPointer() CBotVarClass* CBotVarClass::Find(long id) { - CBotVarClass* p = m_ExClass; + CBotVarClass* p = m_ExClass; - while ( p != NULL ) - { - if ( p->m_ItemIdent == id ) return p; - p = p->m_ExNext; - } + while ( p != NULL ) + { + if ( p->m_ItemIdent == id ) return p; + p = p->m_ExNext; + } - return NULL; + return NULL; } bool CBotVarClass::Eq(CBotVar* left, CBotVar* right) { - CBotVar* l = left->GivItemList(); - CBotVar* r = right->GivItemList(); + CBotVar* l = left->GivItemList(); + CBotVar* r = right->GivItemList(); - while ( l != NULL && r != NULL ) - { - if ( l->Ne(l, r) ) return false; - l = l->GivNext(); - r = r->GivNext(); - } + while ( l != NULL && r != NULL ) + { + if ( l->Ne(l, r) ) return false; + l = l->GivNext(); + r = r->GivNext(); + } - // devrait toujours arrivé simultanément au bout (mêmes classes) - return l == r; + // devrait toujours arrivé simultanément au bout (mêmes classes) + return l == r; } bool CBotVarClass::Ne(CBotVar* left, CBotVar* right) { - CBotVar* l = left->GivItemList(); - CBotVar* r = right->GivItemList(); + CBotVar* l = left->GivItemList(); + CBotVar* r = right->GivItemList(); - while ( l != NULL && r != NULL ) - { - if ( l->Ne(l, r) ) return true; - l = l->GivNext(); - r = r->GivNext(); - } + while ( l != NULL && r != NULL ) + { + if ( l->Ne(l, r) ) return true; + l = l->GivNext(); + r = r->GivNext(); + } - // devrait toujours arrivé simultanément au bout (mêmes classes) - return l != r; + // devrait toujours arrivé simultanément au bout (mêmes classes) + return l != r; } ///////////////////////////////////////////////////////////////////////////// @@ -1765,109 +1765,109 @@ bool CBotVarClass::Ne(CBotVar* left, CBotVar* right) CBotVarArray::CBotVarArray(const CBotToken* name, CBotTypResult& type ) { - if ( !type.Eq(CBotTypArrayPointer) && - !type.Eq(CBotTypArrayBody)) ASM_TRAP(); + if ( !type.Eq(CBotTypArrayPointer) && + !type.Eq(CBotTypArrayBody)) ASM_TRAP(); - m_token = new CBotToken(name); - m_next = NULL; - m_pMyThis = NULL; - m_pUserPtr = NULL; + m_token = new CBotToken(name); + m_next = NULL; + m_pMyThis = NULL; + m_pUserPtr = NULL; - m_type = type; - m_type.SetType(CBotTypArrayPointer); - m_binit = false; + m_type = type; + m_type.SetType(CBotTypArrayPointer); + m_binit = false; - m_pInstance = NULL; // la liste des éléments du tableau + m_pInstance = NULL; // la liste des éléments du tableau } CBotVarArray::~CBotVarArray() { - if ( m_pInstance != NULL ) m_pInstance->DecrementUse(); // une référence en moins + if ( m_pInstance != NULL ) m_pInstance->DecrementUse(); // une référence en moins } // copie une variable dans une autre void CBotVarArray::Copy(CBotVar* pSrc, bool bName) { - if ( pSrc->GivType() != CBotTypArrayPointer ) - ASM_TRAP(); + if ( pSrc->GivType() != CBotTypArrayPointer ) + ASM_TRAP(); - CBotVarArray* p = (CBotVarArray*)pSrc; + CBotVarArray* p = (CBotVarArray*)pSrc; - if ( bName) *m_token = *p->m_token; - m_type = p->m_type; - m_pInstance = p->GivPointer(); + if ( bName) *m_token = *p->m_token; + m_type = p->m_type; + m_pInstance = p->GivPointer(); - if ( m_pInstance != NULL ) - m_pInstance->IncrementUse(); // une référence en plus + if ( m_pInstance != NULL ) + m_pInstance->IncrementUse(); // une référence en plus - m_binit = p->m_binit; -//- m_bStatic = p->m_bStatic; - m_pMyThis = NULL;//p->m_pMyThis; - m_pUserPtr = p->m_pUserPtr; + m_binit = p->m_binit; +//- m_bStatic = p->m_bStatic; + m_pMyThis = NULL;//p->m_pMyThis; + m_pUserPtr = p->m_pUserPtr; - // garde le même idendificateur (par défaut) - if (m_ident == 0 ) m_ident = p->m_ident; + // garde le même idendificateur (par défaut) + if (m_ident == 0 ) m_ident = p->m_ident; } void CBotVarArray::SetPointer(CBotVar* pVarClass) { - m_binit = true; // init, même sur un pointeur null + m_binit = true; // init, même sur un pointeur null - if ( m_pInstance == pVarClass) return; // spécial, ne pas décrémenter et réincrémenter - // car le décrément peut détruire l'object + if ( m_pInstance == pVarClass) return; // spécial, ne pas décrémenter et réincrémenter + // car le décrément peut détruire l'object - if ( pVarClass != NULL ) - { - if ( pVarClass->GivType() == CBotTypArrayPointer ) - pVarClass = pVarClass->GivPointer(); // le vrai pointeur à l'objet + if ( pVarClass != NULL ) + { + if ( pVarClass->GivType() == CBotTypArrayPointer ) + pVarClass = pVarClass->GivPointer(); // le vrai pointeur à l'objet - if ( !pVarClass->m_type.Eq(CBotTypClass) && - !pVarClass->m_type.Eq(CBotTypArrayBody)) - ASM_TRAP(); + if ( !pVarClass->m_type.Eq(CBotTypClass) && + !pVarClass->m_type.Eq(CBotTypArrayBody)) + ASM_TRAP(); - ((CBotVarClass*)pVarClass)->IncrementUse(); // une référence en plus - } + ((CBotVarClass*)pVarClass)->IncrementUse(); // une référence en plus + } - if ( m_pInstance != NULL ) m_pInstance->DecrementUse(); - m_pInstance = (CBotVarClass*)pVarClass; + if ( m_pInstance != NULL ) m_pInstance->DecrementUse(); + m_pInstance = (CBotVarClass*)pVarClass; } CBotVarClass* CBotVarArray::GivPointer() { - if ( m_pInstance == NULL ) return NULL; - return m_pInstance->GivPointer(); + if ( m_pInstance == NULL ) return NULL; + return m_pInstance->GivPointer(); } CBotVar* CBotVarArray::GivItem(int n, bool bExtend) { - if ( m_pInstance == NULL ) - { - if ( !bExtend ) return NULL; - // crée une instance pour le tableau + if ( m_pInstance == NULL ) + { + if ( !bExtend ) return NULL; + // crée une instance pour le tableau - CBotVarClass* instance = new CBotVarClass(NULL, m_type); - SetPointer( instance ); - } - return m_pInstance->GivItem(n, bExtend); + CBotVarClass* instance = new CBotVarClass(NULL, m_type); + SetPointer( instance ); + } + return m_pInstance->GivItem(n, bExtend); } CBotVar* CBotVarArray::GivItemList() { - if ( m_pInstance == NULL) return NULL; - return m_pInstance->GivItemList(); + if ( m_pInstance == NULL) return NULL; + return m_pInstance->GivItemList(); } CBotString CBotVarArray::GivValString() { - if ( m_pInstance == NULL ) return ( CBotString( "Null pointer" ) ) ; - return m_pInstance->GivValString(); + if ( m_pInstance == NULL ) return ( CBotString( "Null pointer" ) ) ; + return m_pInstance->GivValString(); } bool CBotVarArray::Save1State(FILE* pf) { - if ( !WriteType(pf, m_type) ) return false; - return SaveVar(pf, m_pInstance); // sauve l'instance qui gère le tableau + if ( !WriteType(pf, m_type) ) return false; + return SaveVar(pf, m_pInstance); // sauve l'instance qui gère le tableau } @@ -1876,204 +1876,204 @@ bool CBotVarArray::Save1State(FILE* pf) CBotVarPointer::CBotVarPointer(const CBotToken* name, CBotTypResult& type ) { - if ( !type.Eq(CBotTypPointer) && - !type.Eq(CBotTypNullPointer) && - !type.Eq(CBotTypClass) && // par commodité accepte Class et Intrinsic - !type.Eq(CBotTypIntrinsic) ) ASM_TRAP(); + if ( !type.Eq(CBotTypPointer) && + !type.Eq(CBotTypNullPointer) && + !type.Eq(CBotTypClass) && // par commodité accepte Class et Intrinsic + !type.Eq(CBotTypIntrinsic) ) ASM_TRAP(); - m_token = new CBotToken(name); - m_next = NULL; - m_pMyThis = NULL; - m_pUserPtr = NULL; + m_token = new CBotToken(name); + m_next = NULL; + m_pMyThis = NULL; + m_pUserPtr = NULL; - m_type = type; - if ( !type.Eq(CBotTypNullPointer) ) - m_type.SetType(CBotTypPointer); // quoi qu'il en soit, c'est un pointeur - m_binit = false; - m_pClass = NULL; - m_pVarClass = NULL; // sera défini par un SetPointer() + m_type = type; + if ( !type.Eq(CBotTypNullPointer) ) + m_type.SetType(CBotTypPointer); // quoi qu'il en soit, c'est un pointeur + m_binit = false; + m_pClass = NULL; + m_pVarClass = NULL; // sera défini par un SetPointer() - SetClass(type.GivClass() ); + SetClass(type.GivClass() ); } CBotVarPointer::~CBotVarPointer() { - if ( m_pVarClass != NULL ) m_pVarClass->DecrementUse(); // une référence en moins + if ( m_pVarClass != NULL ) m_pVarClass->DecrementUse(); // une référence en moins } void CBotVarPointer::Maj(void* pUser, bool bContinu) { -/* if ( !bContinu && m_pMyThis != NULL ) - m_pMyThis->Maj(pUser, false);*/ +/* if ( !bContinu && m_pMyThis != NULL ) + m_pMyThis->Maj(pUser, false);*/ - if ( m_pVarClass != NULL) m_pVarClass->Maj(pUser, false); + if ( m_pVarClass != NULL) m_pVarClass->Maj(pUser, false); } CBotVar* CBotVarPointer::GivItem(const char* name) { - if ( m_pVarClass == NULL) // pas d'instance existant ? - return m_pClass->GivItem(name); // rend le pointeur dans la classe elle-même + if ( m_pVarClass == NULL) // pas d'instance existant ? + return m_pClass->GivItem(name); // rend le pointeur dans la classe elle-même - return m_pVarClass->GivItem(name); + return m_pVarClass->GivItem(name); } CBotVar* CBotVarPointer::GivItemRef(int nIdent) { - if ( m_pVarClass == NULL) // pas d'instance existant ? - return m_pClass->GivItemRef(nIdent);// rend le pointeur dans la classe elle-même + if ( m_pVarClass == NULL) // pas d'instance existant ? + return m_pClass->GivItemRef(nIdent);// rend le pointeur dans la classe elle-même - return m_pVarClass->GivItemRef(nIdent); + return m_pVarClass->GivItemRef(nIdent); } CBotVar* CBotVarPointer::GivItemList() { - if ( m_pVarClass == NULL) return NULL; - return m_pVarClass->GivItemList(); + if ( m_pVarClass == NULL) return NULL; + return m_pVarClass->GivItemList(); } CBotString CBotVarPointer::GivValString() { - CBotString s = "Pointer to "; - if ( m_pVarClass == NULL ) s = "Null pointer" ; - else s += m_pVarClass->GivValString(); - return s; + CBotString s = "Pointer to "; + if ( m_pVarClass == NULL ) s = "Null pointer" ; + else s += m_pVarClass->GivValString(); + return s; } void CBotVarPointer::ConstructorSet() { - if ( m_pVarClass != NULL) m_pVarClass->ConstructorSet(); + if ( m_pVarClass != NULL) m_pVarClass->ConstructorSet(); } // initialise le pointeur vers l'instance d'une classe void CBotVarPointer::SetPointer(CBotVar* pVarClass) { - m_binit = true; // init, même sur un pointeur null + m_binit = true; // init, même sur un pointeur null - if ( m_pVarClass == pVarClass) return; // spécial, ne pas décrémenter et réincrémenter - // car le décrément peut détruire l'object + if ( m_pVarClass == pVarClass) return; // spécial, ne pas décrémenter et réincrémenter + // car le décrément peut détruire l'object - if ( pVarClass != NULL ) - { - if ( pVarClass->GivType() == CBotTypPointer ) - pVarClass = pVarClass->GivPointer(); // le vrai pointeur à l'objet + if ( pVarClass != NULL ) + { + if ( pVarClass->GivType() == CBotTypPointer ) + pVarClass = pVarClass->GivPointer(); // le vrai pointeur à l'objet -// if ( pVarClass->GivType() != CBotTypClass ) - if ( !pVarClass->m_type.Eq(CBotTypClass) ) - ASM_TRAP(); +// if ( pVarClass->GivType() != CBotTypClass ) + if ( !pVarClass->m_type.Eq(CBotTypClass) ) + ASM_TRAP(); - ((CBotVarClass*)pVarClass)->IncrementUse(); // une référence en plus - m_pClass = ((CBotVarClass*)pVarClass)->m_pClass; - m_pUserPtr = pVarClass->m_pUserPtr; // pas vraiment indispensable - m_type = CBotTypResult(CBotTypPointer, m_pClass); // un pointeur de quel genre - } + ((CBotVarClass*)pVarClass)->IncrementUse(); // une référence en plus + m_pClass = ((CBotVarClass*)pVarClass)->m_pClass; + m_pUserPtr = pVarClass->m_pUserPtr; // pas vraiment indispensable + m_type = CBotTypResult(CBotTypPointer, m_pClass); // un pointeur de quel genre + } - if ( m_pVarClass != NULL ) m_pVarClass->DecrementUse(); - m_pVarClass = (CBotVarClass*)pVarClass; + if ( m_pVarClass != NULL ) m_pVarClass->DecrementUse(); + m_pVarClass = (CBotVarClass*)pVarClass; } CBotVarClass* CBotVarPointer::GivPointer() { - if ( m_pVarClass == NULL ) return NULL; - return m_pVarClass->GivPointer(); + if ( m_pVarClass == NULL ) return NULL; + return m_pVarClass->GivPointer(); } void CBotVarPointer::SetIdent(long n) { - if ( m_pVarClass == NULL ) return; - m_pVarClass->SetIdent( n ); + if ( m_pVarClass == NULL ) return; + m_pVarClass->SetIdent( n ); } long CBotVarPointer::GivIdent() { - if ( m_pVarClass == NULL ) return 0; - return m_pVarClass->m_ItemIdent; + if ( m_pVarClass == NULL ) return 0; + return m_pVarClass->m_ItemIdent; } void CBotVarPointer::SetClass(CBotClass* pClass) { -// int nIdent = 0; - m_type.m_pClass = m_pClass = pClass; - if ( m_pVarClass != NULL ) m_pVarClass->SetClass(pClass); //, nIdent); +// int nIdent = 0; + m_type.m_pClass = m_pClass = pClass; + if ( m_pVarClass != NULL ) m_pVarClass->SetClass(pClass); //, nIdent); } CBotClass* CBotVarPointer::GivClass() { - if ( m_pVarClass != NULL ) return m_pVarClass->GivClass(); + if ( m_pVarClass != NULL ) return m_pVarClass->GivClass(); - return m_pClass; + return m_pClass; } bool CBotVarPointer::Save1State(FILE* pf) { - if ( m_pClass ) - { - if (!WriteString(pf, m_pClass->GivName())) return false; // nom de la classe - } - else - { - if (!WriteString(pf, "")) return false; - } + if ( m_pClass ) + { + if (!WriteString(pf, m_pClass->GivName())) return false; // nom de la classe + } + else + { + if (!WriteString(pf, "")) return false; + } - if (!WriteLong(pf, GivIdent())) return false; // la référence unique + if (!WriteLong(pf, GivIdent())) return false; // la référence unique - // sauve aussi une copie de l'instance - return SaveVar(pf, GivPointer()); + // sauve aussi une copie de l'instance + return SaveVar(pf, GivPointer()); } // copie une variable dans une autre void CBotVarPointer::Copy(CBotVar* pSrc, bool bName) { - if ( pSrc->GivType() != CBotTypPointer && - pSrc->GivType() != CBotTypNullPointer) - ASM_TRAP(); + if ( pSrc->GivType() != CBotTypPointer && + pSrc->GivType() != CBotTypNullPointer) + ASM_TRAP(); - CBotVarPointer* p = (CBotVarPointer*)pSrc; + CBotVarPointer* p = (CBotVarPointer*)pSrc; - if ( bName) *m_token = *p->m_token; - m_type = p->m_type; -// m_pVarClass = p->m_pVarClass; - m_pVarClass = p->GivPointer(); + if ( bName) *m_token = *p->m_token; + m_type = p->m_type; +// m_pVarClass = p->m_pVarClass; + m_pVarClass = p->GivPointer(); - if ( m_pVarClass != NULL ) - m_pVarClass->IncrementUse(); // une référence en plus + if ( m_pVarClass != NULL ) + m_pVarClass->IncrementUse(); // une référence en plus - m_pClass = p->m_pClass; - m_binit = p->m_binit; -//- m_bStatic = p->m_bStatic; - m_next = NULL; - m_pMyThis = NULL;//p->m_pMyThis; - m_pUserPtr = p->m_pUserPtr; + m_pClass = p->m_pClass; + m_binit = p->m_binit; +//- m_bStatic = p->m_bStatic; + m_next = NULL; + m_pMyThis = NULL;//p->m_pMyThis; + m_pUserPtr = p->m_pUserPtr; - // garde le même idendificateur (par défaut) - if (m_ident == 0 ) m_ident = p->m_ident; + // garde le même idendificateur (par défaut) + if (m_ident == 0 ) m_ident = p->m_ident; } bool CBotVarPointer::Eq(CBotVar* left, CBotVar* right) { - CBotVarClass* l = left->GivPointer(); - CBotVarClass* r = right->GivPointer(); + CBotVarClass* l = left->GivPointer(); + CBotVarClass* r = right->GivPointer(); - if ( l == r ) return true; - if ( l == NULL && r->GivUserPtr() == OBJECTDELETED ) return true; - if ( r == NULL && l->GivUserPtr() == OBJECTDELETED ) return true; - return false; + if ( l == r ) return true; + if ( l == NULL && r->GivUserPtr() == OBJECTDELETED ) return true; + if ( r == NULL && l->GivUserPtr() == OBJECTDELETED ) return true; + return false; } bool CBotVarPointer::Ne(CBotVar* left, CBotVar* right) { - CBotVarClass* l = left->GivPointer(); - CBotVarClass* r = right->GivPointer(); + CBotVarClass* l = left->GivPointer(); + CBotVarClass* r = right->GivPointer(); - if ( l == r ) return false; - if ( l == NULL && r->GivUserPtr() == OBJECTDELETED ) return false; - if ( r == NULL && l->GivUserPtr() == OBJECTDELETED ) return false; - return true; + if ( l == r ) return false; + if ( l == NULL && r->GivUserPtr() == OBJECTDELETED ) return false; + if ( r == NULL && l->GivUserPtr() == OBJECTDELETED ) return false; + return true; } @@ -2084,162 +2084,162 @@ bool CBotVarPointer::Ne(CBotVar* left, CBotVar* right) CBotTypResult::CBotTypResult(int type) { - m_type = type; - m_pNext = NULL; - m_pClass = NULL; - m_limite = -1; + m_type = type; + m_pNext = NULL; + m_pClass = NULL; + m_limite = -1; } CBotTypResult::CBotTypResult(int type, const char* name) { - m_type = type; - m_pNext = NULL; - m_pClass = NULL; - m_limite = -1; + m_type = type; + m_pNext = NULL; + m_pClass = NULL; + m_limite = -1; - if ( type == CBotTypPointer || - type == CBotTypClass || - type == CBotTypIntrinsic ) - { - m_pClass = CBotClass::Find(name); - if ( m_pClass && m_pClass->IsIntrinsic() ) m_type = CBotTypIntrinsic; - } + if ( type == CBotTypPointer || + type == CBotTypClass || + type == CBotTypIntrinsic ) + { + m_pClass = CBotClass::Find(name); + if ( m_pClass && m_pClass->IsIntrinsic() ) m_type = CBotTypIntrinsic; + } } CBotTypResult::CBotTypResult(int type, CBotClass* pClass) { - m_type = type; - m_pNext = NULL; - m_pClass = pClass; - m_limite = -1; + m_type = type; + m_pNext = NULL; + m_pClass = pClass; + m_limite = -1; - if ( m_pClass && m_pClass->IsIntrinsic() ) m_type = CBotTypIntrinsic; + if ( m_pClass && m_pClass->IsIntrinsic() ) m_type = CBotTypIntrinsic; } CBotTypResult::CBotTypResult(int type, CBotTypResult elem) { - m_type = type; - m_pNext = NULL; - m_pClass = NULL; - m_limite = -1; + m_type = type; + m_pNext = NULL; + m_pClass = NULL; + m_limite = -1; - if ( type == CBotTypArrayPointer || - type == CBotTypArrayBody ) - m_pNext = new CBotTypResult( elem ); + if ( type == CBotTypArrayPointer || + type == CBotTypArrayBody ) + m_pNext = new CBotTypResult( elem ); } CBotTypResult::CBotTypResult(const CBotTypResult& typ) { - m_type = typ.m_type; - m_pClass = typ.m_pClass; - m_pNext = NULL; - m_limite = typ.m_limite; + m_type = typ.m_type; + m_pClass = typ.m_pClass; + m_pNext = NULL; + m_limite = typ.m_limite; - if ( typ.m_pNext ) - m_pNext = new CBotTypResult( *typ.m_pNext ); + if ( typ.m_pNext ) + m_pNext = new CBotTypResult( *typ.m_pNext ); } CBotTypResult::CBotTypResult() { - m_type = 0; - m_limite = -1; - m_pNext = NULL; - m_pClass = NULL; + m_type = 0; + m_limite = -1; + m_pNext = NULL; + m_pClass = NULL; } CBotTypResult::~CBotTypResult() { - delete m_pNext; + delete m_pNext; } int CBotTypResult::GivType(int mode) const { -#ifdef _DEBUG - if ( m_type == CBotTypPointer || - m_type == CBotTypClass || - m_type == CBotTypIntrinsic ) +#ifdef _DEBUG + if ( m_type == CBotTypPointer || + m_type == CBotTypClass || + m_type == CBotTypIntrinsic ) - if ( m_pClass == NULL ) ASM_TRAP(); + if ( m_pClass == NULL ) ASM_TRAP(); - - if ( m_type == CBotTypArrayPointer ) - if ( m_pNext == NULL ) ASM_TRAP(); + + if ( m_type == CBotTypArrayPointer ) + if ( m_pNext == NULL ) ASM_TRAP(); #endif - if ( mode == 3 && m_type == CBotTypNullPointer ) return CBotTypPointer; - return m_type; + if ( mode == 3 && m_type == CBotTypNullPointer ) return CBotTypPointer; + return m_type; } void CBotTypResult::SetType(int n) { - m_type = n; + m_type = n; } CBotClass* CBotTypResult::GivClass() const { - return m_pClass; + return m_pClass; } CBotTypResult& CBotTypResult::GivTypElem() const { - return *m_pNext; + return *m_pNext; } int CBotTypResult::GivLimite() const { - return m_limite; + return m_limite; } void CBotTypResult::SetLimite(int n) { - m_limite = n; + m_limite = n; } void CBotTypResult::SetArray( int* max ) { - m_limite = *max; - if (m_limite < 1) m_limite = -1; + m_limite = *max; + if (m_limite < 1) m_limite = -1; - if ( m_pNext != NULL ) // dernière dimension ? - { - m_pNext->SetArray( max+1 ); - } + if ( m_pNext != NULL ) // dernière dimension ? + { + m_pNext->SetArray( max+1 ); + } } bool CBotTypResult::Compare(const CBotTypResult& typ) const { - if ( m_type != typ.m_type ) return false; + if ( m_type != typ.m_type ) return false; - if ( m_type == CBotTypArrayPointer ) return m_pNext->Compare(*typ.m_pNext); + if ( m_type == CBotTypArrayPointer ) return m_pNext->Compare(*typ.m_pNext); - if ( m_type == CBotTypPointer || - m_type == CBotTypClass || - m_type == CBotTypIntrinsic ) - { - return m_pClass == typ.m_pClass; - } + if ( m_type == CBotTypPointer || + m_type == CBotTypClass || + m_type == CBotTypIntrinsic ) + { + return m_pClass == typ.m_pClass; + } - return true; + return true; } bool CBotTypResult::Eq(int type) const { - return m_type == type; + return m_type == type; } CBotTypResult& - CBotTypResult::operator=(const CBotTypResult& src) -{ - m_type = src.m_type; - m_limite = src.m_limite; - m_pClass = src.m_pClass; - m_pNext = NULL; - if ( src.m_pNext != NULL ) - { - m_pNext = new CBotTypResult(*src.m_pNext); - } - return *this; + CBotTypResult::operator=(const CBotTypResult& src) +{ + m_type = src.m_type; + m_limite = src.m_limite; + m_pClass = src.m_pClass; + m_pNext = NULL; + if ( src.m_pNext != NULL ) + { + m_pNext = new CBotTypResult(*src.m_pNext); + } + return *this; } diff --git a/src/CBot/resource.h b/src/CBot/resource.h index f82fb9c..6bf48e1 100644 --- a/src/CBot/resource.h +++ b/src/CBot/resource.h @@ -13,8 +13,6 @@ // * // * 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}} -// Microsoft Developer Studio generated include file. -// Used by CBot.rc #ifndef _RESOURCE_H_ #define _RESOURCE_H_ -- cgit v1.2.3-1-g7c22