From b2589d2f6afb91b229ca19bea9f778f38068dd20 Mon Sep 17 00:00:00 2001 From: Programerus Date: Wed, 11 Apr 2012 23:16:24 +0200 Subject: Unneeded files deleted. --- "src/CBot/CBotTwoOpExpr ordre invers\351.cpp" | 314 -------------------------- 1 file changed, 314 deletions(-) delete mode 100644 "src/CBot/CBotTwoOpExpr ordre invers\351.cpp" (limited to 'src/CBot/CBotTwoOpExpr ordre inversé.cpp') diff --git "a/src/CBot/CBotTwoOpExpr ordre invers\351.cpp" "b/src/CBot/CBotTwoOpExpr ordre invers\351.cpp" deleted file mode 100644 index e34e26f..0000000 --- "a/src/CBot/CBotTwoOpExpr ordre invers\351.cpp" +++ /dev/null @@ -1,314 +0,0 @@ -// * This file is part of the COLOBOT source code -// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch -// * -// * This program is free software: you can redistribute it and/or modify -// * it under the terms of the GNU General Public License as published by -// * the Free Software Foundation, either version 3 of the License, or -// * (at your option) any later version. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU General Public License -// * along with this program. If not, see http://www.gnu.org/licenses/. - -#include "CBot.h" - -// divers constructeurs - -CBotTwoOpExpr::CBotTwoOpExpr() -{ - m_leftop = - m_rightop = NULL; // NULL pour pouvoir faire delete sans autre - name = "CBotTwoOpExpr"; // debug -} - -CBotTwoOpExpr::~CBotTwoOpExpr() -{ - delete m_leftop; - delete m_rightop; -} - -// type d'op�randes accept�s par les op�rations -#define ENTIER ((1<TokenStack(); // un bout de pile svp - - // cherche des instructions qui peuvent convenir � gauche de l'op�ration - CBotInstr* left = CBotParExpr::Compile( p, pStk ) ; // expression (...) � gauche - - if (left == NULL) return pStack->Return(NULL, pStk); // si erreur, la transmet - - - CBotToken* pp = p; - int TypeOp = pp->GetType(); // type d'op�ration - p = p->Next(); // saute le token de l'op�ration - - // cherche des instructions qui peuvent convenir � droite - - CBotInstr* right = (*pOp == 0) ? - CBotParExpr::Compile( p, pStk ) : // expression (...) � droite - CBotTwoOpExpr::Compile( p, pStk, pOp ); // expression A op B � droite - - if (right == NULL) return pStack->Return(left, pStk); // pas d'op�rande � droite ? - - // est-ce qu'on a l'op�ration pr�vue entre les deux ? - if ( IsInList( TypeOp, pOperations, typemasque ) ) - { - CBotTwoOpExpr* inst = new CBotTwoOpExpr(); // �l�ment pour op�ration - inst->SetToken(pp); // m�morise l'op�ration - - int type1, type2; - type1 = pStk->GetType(); // de quel type le premier op�rande ? - - inst->m_rightop = right; - { - // il y a un second op�rande acceptable - - type2 = pStk->GetType(); // de quel type le r�sultat ? - - // quel est le type du r�sultat ? - int TypeRes = MAX( type1, type2 ); - if (!TypeOk( TypeRes, typemasque )) type1 = 99; // erreur de type - - switch ( TypeOp ) - { - case ID_LOG_OR: - case ID_LOG_AND: - case ID_EQ: - case ID_NE: - case ID_HI: - case ID_LO: - case ID_HS: - case ID_LS: - TypeRes = CBotTypBoolean; - } - if ( TypeCompatible (type1, type2) || // les r�sultats sont-ils compatibles - // cas particulier pour les concat�nation de cha�nes - (TypeOp == ID_ADD && (type1 == CBotTypString || type2 == CBotTypString))) - { - // si ok, enregistre l'op�rande dans l'objet - inst->m_leftop = left; - // met une variable sur la pile pour avoir le type de r�sultat - pStk->SetVar(new CBotVar(NULL, TypeRes)); - // et rend l'object � qui l'a demand� - return pStack->Return(inst, pStk); - } - pStk->SetError(TX_BAD2TYPE, &inst->m_token); - } - - // en cas d'erreur, lib�re les �l�ments - delete left; - delete inst; - // et transmet l'erreur qui se trouve sur la pile - return pStack->Return(NULL, pStk); - } - - // si on n'a pas affaire � une op�ration + ou - - // rend � qui l'a demand�, l'op�rande (de gauche) trouv� - // � la place de l'objet "addition" - return pStack->Return(left, pStk); -} - - - - -// fait l'op�ration d'addition ou de soustraction - -BOOL CBotTwoOpExpr::Execute(CBotStack* &pStack) -{ - CBotStack* pStk1 = pStack->AddStack(); // ajoute un �l�ment � la pile - // ou le retrouve en cas de reprise -// if ( pStk1 == EOX ) return TRUE; - - - // selon la reprise, on peut �tre dans l'un des 2 �tats - - if ( pStk1->GetState() == 0 && // 1er �tat, �value l'op�rande de gauche - !m_leftop->Execute(pStk1) ) return FALSE; // interrompu ici ? - - // passe � l'�tape suivante - pStk1->SetState(1); // pr�t pour la suite - - // pour les OU et ET logique, n'�value pas la seconde expression si pas n�cessaire - if ( GetTokenType() == ID_LOG_AND && pStk1->GetVal() == FALSE ) - { - CBotVar* res = CBotVar::Create( NULL, CBotTypBoolean); - res->SetValInt(FALSE); - pStk1->SetVar(res); - return pStack->Return(pStk1); // transmet le r�sultat - } - if ( GetTokenType() == ID_LOG_OR && pStk1->GetVal() == TRUE ) - { - CBotVar* res = CBotVar::Create( NULL, CBotTypBoolean); - res->SetValInt(TRUE); - pStk1->SetVar(res); - return pStack->Return(pStk1); // transmet le r�sultat - } - - // demande un peu plus de stack pour ne pas toucher le r�sultat de gauche - // qui se trouve sur la pile, justement. - - CBotStack* pStk2 = pStk1->AddStack(); // ajoute un �l�ment � la pile - // ou le retrouve en cas de reprise - - // 2e �tat, �value l'op�rande de droite - if ( !m_rightop->Execute(pStk2) ) return FALSE; // interrompu ici ? - - int type1 = pStk1->GetType(); // de quels types les r�sultats ? - int type2 = pStk2->GetType(); - - // cr�e une variable temporaire pour y mettre le r�sultat - // quel est le type du r�sultat ? - int TypeRes = MAX(type1, type2); - switch ( GetTokenType() ) - { - case ID_LOG_OR: - case ID_LOG_AND: - case ID_EQ: - case ID_NE: - case ID_HI: - case ID_LO: - case ID_HS: - case ID_LS: - TypeRes = CBotTypBoolean; - } - CBotVar* result = CBotVar::Create( NULL, TypeRes); - CBotVar* temp = CBotVar::Create( NULL, MAX(type1, type2) ); - - int err = 0; - // fait l'op�ration selon la demande - switch (GetTokenType()) - { - case ID_ADD: - result->Add(pStk1->GetVar(), pStk2->GetVar()); // additionne - break; - case ID_SUB: - result->Sub(pStk1->GetVar(), pStk2->GetVar()); // soustrait - break; - case ID_MUL: - result->Mul(pStk1->GetVar(), pStk2->GetVar()); // multiplie - break; - case ID_DIV: - err = result->Div(pStk1->GetVar(), pStk2->GetVar());// divise - break; - case ID_MODULO: - err = result->Modulo(pStk1->GetVar(), pStk2->GetVar());// reste de division - break; - case ID_LO: - temp->Lo(pStk1->GetVar(), pStk2->GetVar()); // inf�rieur - result->SetValInt(temp->GetValInt()); // converti le r�sultat - break; - case ID_HI: - temp->Hi(pStk1->GetVar(), pStk2->GetVar()); // sup�rieur - result->SetValInt(temp->GetValInt()); // converti le r�sultat - break; - case ID_LS: - temp->Ls(pStk1->GetVar(), pStk2->GetVar()); // inf�rieur ou �gal - result->SetValInt(temp->GetValInt()); // converti le r�sultat - break; - case ID_HS: - temp->Hs(pStk1->GetVar(), pStk2->GetVar()); // sup�rieur ou �gal - result->SetValInt(temp->GetValInt()); // converti le r�sultat - break; - case ID_EQ: - temp->Eq(pStk1->GetVar(), pStk2->GetVar()); // �gal - result->SetValInt(temp->GetValInt()); // converti le r�sultat - break; - case ID_NE: - temp->Ne(pStk1->GetVar(), pStk2->GetVar()); // diff�rent - result->SetValInt(temp->GetValInt()); // converti le r�sultat - break; - case ID_LOG_AND: - case ID_AND: - result->And(pStk1->GetVar(), pStk2->GetVar()); // ET - break; - case ID_LOG_OR: - case ID_OR: - result->Or(pStk1->GetVar(), pStk2->GetVar()); // OU - break; - case ID_XOR: - result->XOr(pStk1->GetVar(), pStk2->GetVar()); // OU exclusif - break; - case ID_ASR: - result->ASR(pStk1->GetVar(), pStk2->GetVar()); - break; - case ID_SR: - result->SR(pStk1->GetVar(), pStk2->GetVar()); - break; - case ID_SL: - result->SL(pStk1->GetVar(), pStk2->GetVar()); - break; - default: - __asm int 3; - } - delete temp; - - pStk2->SetVar(result); // met le r�sultat sur la pile - if ( err ) pStk2->SetError(err, &m_token); // et l'erreur �ventuelle (division par z�ro) - - pStk1->Return(pStk2); // lib�re la pile - return pStack->Return(pStk1); // transmet le r�sultat -} - - -- cgit v1.2.3-1-g7c22