From aab79c6b5dc33f2a0f88b42a5308e79aeeb92b2c Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 25 Nov 2013 20:03:06 +0100 Subject: Changed ASM_TRAP() to assert(0) --- src/CBot/CBot.cpp | 29 ++++++------ src/CBot/CBot.h | 7 --- src/CBot/CBotFunction.cpp | 5 +- src/CBot/CBotStack.cpp | 12 +++-- src/CBot/CBotTwoOpExpr.cpp | 4 +- src/CBot/CBotVar.cpp | 114 +++++++++++++++++++++++---------------------- 6 files changed, 88 insertions(+), 83 deletions(-) diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp index 513b803..403be6e 100644 --- a/src/CBot/CBot.cpp +++ b/src/CBot/CBot.cpp @@ -33,6 +33,9 @@ #include "CBot.h" +#include + + CBotInstr::CBotInstr() { name = "CBotInstr"; @@ -285,7 +288,7 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack) bool CBotInstr::Execute(CBotStack* &pj) { CBotString ClassManquante = name; - ASM_TRAP(); // should never go through this routine + assert(0); // should never go through this routine // but use the routines of the subclasses return false; } @@ -300,26 +303,26 @@ bool CBotInstr::Execute(CBotStack* &pj, CBotVar* pVar) void CBotInstr::RestoreState(CBotStack* &pj, bool bMain) { CBotString ClassManquante = name; - ASM_TRAP(); // should never go through this routine + assert(0); // should never go through this routine // but use the routines of the subclasses } bool CBotInstr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) { - ASM_TRAP(); // dad do not know, see the girls + assert(0); // dad do not know, see the girls return false; } bool CBotInstr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep, bool bExtend) { - ASM_TRAP(); // dad do not know, see the girls + assert(0); // dad do not know, see the girls return false; } void CBotInstr::RestoreStateVar(CBotStack* &pile, bool bMain) { - ASM_TRAP(); // dad do not know, see the girls + assert(0); // dad do not know, see the girls } // this routine is defined only for the subclass CBotCase @@ -531,7 +534,7 @@ void CBotLeftExprVar::RestoreState(CBotStack* &pj, bool bMain) CBotVar* var1; var1 = pj->FindVar(m_token.GetString()); - if (var1 == NULL) ASM_TRAP(); + if (var1 == NULL) assert(0); var1->SetUniqNum(m_nIdent); // with the unique identifier } @@ -1747,7 +1750,7 @@ bool CBotExpression::Execute(CBotStack* &pj) pile2->SetVar(result); break; default: - ASM_TRAP(); + assert(0); } if (!IsInit) pile2->SetError(TX_NOTINIT, m_leftop->GetToken()); @@ -2270,7 +2273,7 @@ CBotIndexExpr::~CBotIndexExpr() bool CBotIndexExpr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) { if (pVar->GetType(1) != CBotTypArrayPointer) - ASM_TRAP(); + assert(0); pVar = (static_cast(pVar))->GetItem(0, false); // at compile time makes the element [0] if (pVar == NULL) @@ -2291,7 +2294,7 @@ bool CBotIndexExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prev CBotStack* pj = pile; if (pVar->GetType(1) != CBotTypArrayPointer) - ASM_TRAP(); + assert(0); pile = pile->AddStack(); @@ -2372,7 +2375,7 @@ void CBotFieldExpr::SetUniqNum(int num) bool CBotFieldExpr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) { if (pVar->GetType(1) != CBotTypPointer) - ASM_TRAP(); + assert(0); pVar = pVar->GetItemRef(m_nIdent); if (pVar == NULL) @@ -2395,7 +2398,7 @@ bool CBotFieldExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prev if (pVar->GetType(1) != CBotTypPointer) - ASM_TRAP(); + assert(0); CBotVarClass* pItem = pVar->GetPointer(); if (pItem == NULL) @@ -2648,7 +2651,7 @@ bool CBotLeftExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevT if (pVar == NULL) { #ifdef _DEBUG - ASM_TRAP(); + assert(0); #endif pile->SetError(2, &m_token); return false; @@ -3289,7 +3292,7 @@ bool CBotExprVar::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToke if (pVar == NULL) { #ifdef _DEBUG - ASM_TRAP(); + assert(0); #endif pj->SetError(1, &m_token); return false; diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h index 8313252..df6614e 100644 --- a/src/CBot/CBot.h +++ b/src/CBot/CBot.h @@ -32,13 +32,6 @@ #define EOX (reinterpret_cast(-1)) /// \def tag special condition -// fix for MSVC instruction __asm int 3 (setting a trap) -#if defined(__MINGW32__) || defined(__GNUC__) -#define ASM_TRAP() asm("int $3"); -#else -#define ASM_TRAP() __asm int 3; -#endif - ///////////////////////////////////////////////////////////////////// // forward declaration diff --git a/src/CBot/CBotFunction.cpp b/src/CBot/CBotFunction.cpp index 862554e..e6aa2c9 100644 --- a/src/CBot/CBotFunction.cpp +++ b/src/CBot/CBotFunction.cpp @@ -20,6 +20,9 @@ #include "CBot.h" +#include + + // various constructors / destructors // \TODO translation:to liberate all according to esteblished tree // pour libérer tout selon l'arbre établi @@ -1046,7 +1049,7 @@ bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj) } break; default: - ASM_TRAP(); + assert(0); } } newvar->SetUniqNum(p->m_nIdent); diff --git a/src/CBot/CBotStack.cpp b/src/CBot/CBotStack.cpp index 086442d..1679e5e 100644 --- a/src/CBot/CBotStack.cpp +++ b/src/CBot/CBotStack.cpp @@ -18,6 +18,8 @@ #include "CBot.h" + +#include #include #include @@ -80,12 +82,12 @@ CBotStack* CBotStack::FirstStack() CBotStack::CBotStack(CBotStack* ppapa) { // constructor must exist or the destructor is never called! - ASM_TRAP(); + assert(0); } CBotStack::~CBotStack() { - ASM_TRAP(); // use Delete () instead + assert(0); // use Delete () instead } void CBotStack::Delete() @@ -693,7 +695,7 @@ void CBotStack::AddVar(CBotVar* pVar) *pp = pVar; // added after #ifdef _DEBUG - if ( pVar->GetUniqNum() == 0 ) ASM_TRAP(); + if ( pVar->GetUniqNum() == 0 ) assert(0); #endif } @@ -1091,7 +1093,7 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) } break; default: - ASM_TRAP(); + assert(0); } if ( pPrev != NULL ) pPrev->m_next = pNew; @@ -1388,7 +1390,7 @@ void CBotCStack::AddVar(CBotVar* pVar) *pp = pVar; // added after #ifdef _DEBUG - if ( pVar->GetUniqNum() == 0 ) ASM_TRAP(); + if ( pVar->GetUniqNum() == 0 ) assert(0); #endif } diff --git a/src/CBot/CBotTwoOpExpr.cpp b/src/CBot/CBotTwoOpExpr.cpp index 6a0d636..4d4add8 100644 --- a/src/CBot/CBotTwoOpExpr.cpp +++ b/src/CBot/CBotTwoOpExpr.cpp @@ -20,6 +20,8 @@ #include "CBot.h" +#include + // various constructors CBotTwoOpExpr::CBotTwoOpExpr() @@ -466,7 +468,7 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack) if ( !IsNan(left, right, &err) ) result->SL(left , right); break; default: - ASM_TRAP(); + assert(0); } delete temp; diff --git a/src/CBot/CBotVar.cpp b/src/CBot/CBotVar.cpp index ad3708d..b84006f 100644 --- a/src/CBot/CBotVar.cpp +++ b/src/CBot/CBotVar.cpp @@ -21,8 +21,10 @@ // it never creates an instance of the class mother CBotVar #include "CBot.h" -#include -#include + +#include +#include +#include long CBotVar::m_identcpt = 0; @@ -124,7 +126,7 @@ void CBotVarClass::InitCBotVarClass( const CBotToken* name, CBotTypResult& type !type.Eq(CBotTypIntrinsic) && // by convenience there accepts these types !type.Eq(CBotTypPointer) && !type.Eq(CBotTypArrayPointer) && - !type.Eq(CBotTypArrayBody)) ASM_TRAP(); + !type.Eq(CBotTypArrayBody)) assert(0); m_token = new CBotToken(name); m_next = NULL; @@ -169,7 +171,7 @@ void CBotVarClass::InitCBotVarClass( const CBotToken* name, CBotTypResult& type CBotVarClass::~CBotVarClass( ) { if ( m_CptUse != 0 ) - ASM_TRAP(); + assert(0); if ( m_pParent ) delete m_pParent; m_pParent = NULL; @@ -242,7 +244,7 @@ void CBotVar::SetUniqNum(long n) { m_ident = n; - if ( n == 0 ) ASM_TRAP(); + if ( n == 0 ) assert(0); } long CBotVar::NextUniqNum() @@ -267,7 +269,7 @@ bool CBotVar::Save1State(FILE* pf) // this routine "virtual" must never be called, // there must be a routine for each of the subclasses (CBotVarInt, CBotVarFloat, etc) // ( see the type in m_type ) - ASM_TRAP(); + assert(0); return false; } @@ -335,7 +337,7 @@ CBotVar* CBotVar::Create(const CBotToken* name, CBotTypResult type) } } - ASM_TRAP(); + assert(0); return NULL; } @@ -406,7 +408,7 @@ CBotVar* CBotVar::Create( const char* n, CBotTypResult type) } } - ASM_TRAP(); + assert(0); return NULL; } @@ -519,25 +521,25 @@ CBotToken* CBotVar::GetToken() CBotVar* CBotVar::GetItem(const char* name) { - ASM_TRAP(); + assert(0); return NULL; } CBotVar* CBotVar::GetItemRef(int nIdent) { - ASM_TRAP(); + assert(0); return NULL; } CBotVar* CBotVar::GetItemList() { - ASM_TRAP(); + assert(0); return NULL; } CBotVar* CBotVar::GetItem(int row, bool bGrow) { - ASM_TRAP(); + assert(0); return NULL; } @@ -617,7 +619,7 @@ void CBotVar::SetVal(CBotVar* var) } break; default: - ASM_TRAP(); + assert(0); } m_binit = var->m_binit; // copie l'état nan s'il y a @@ -651,12 +653,12 @@ int CBotVar::GetPrivate() void CBotVar::SetPointer(CBotVar* pVarClass) { - ASM_TRAP(); + assert(0); } CBotVarClass* CBotVar::GetPointer() { - ASM_TRAP(); + assert(0); return NULL; } @@ -665,167 +667,167 @@ CBotVarClass* CBotVar::GetPointer() int CBotVar::GetValInt() { - ASM_TRAP(); + assert(0); return 0; } float CBotVar::GetValFloat() { - ASM_TRAP(); + assert(0); return 0; } void CBotVar::SetValInt(int c, const char* s) { - ASM_TRAP(); + assert(0); } void CBotVar::SetValFloat(float c) { - ASM_TRAP(); + assert(0); } void CBotVar::Mul(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); } void CBotVar::Power(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); } int CBotVar::Div(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); return 0; } int CBotVar::Modulo(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); return 0; } void CBotVar::Add(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); } void CBotVar::Sub(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); } bool CBotVar::Lo(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); return false; } bool CBotVar::Hi(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); return false; } bool CBotVar::Ls(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); return false; } bool CBotVar::Hs(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); return false; } bool CBotVar::Eq(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); return false; } bool CBotVar::Ne(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); return false; } void CBotVar::And(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); } void CBotVar::Or(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); } void CBotVar::XOr(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); } void CBotVar::ASR(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); } void CBotVar::SR(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); } void CBotVar::SL(CBotVar* left, CBotVar* right) { - ASM_TRAP(); + assert(0); } void CBotVar::Neg() { - ASM_TRAP(); + assert(0); } void CBotVar::Not() { - ASM_TRAP(); + assert(0); } void CBotVar::Inc() { - ASM_TRAP(); + assert(0); } void CBotVar::Dec() { - ASM_TRAP(); + assert(0); } void CBotVar::Copy(CBotVar* pSrc, bool bName) { - ASM_TRAP(); + assert(0); } void CBotVar::SetValString(const char* p) { - ASM_TRAP(); + assert(0); } CBotString CBotVar::GetValString() { - ASM_TRAP(); + assert(0); return CBotString(); } void CBotVar::SetClass(CBotClass* pClass) { - ASM_TRAP(); + assert(0); } CBotClass* CBotVar::GetClass() { - ASM_TRAP(); + assert(0); return NULL; } @@ -1398,7 +1400,7 @@ void CBotVarClass::Copy(CBotVar* pSrc, bool bName) pSrc = pSrc->GetPointer(); // if source given by a pointer if ( pSrc->GetType() != CBotTypClass ) - ASM_TRAP(); + assert(0); CBotVarClass* p = static_cast(pSrc); @@ -1410,7 +1412,7 @@ void CBotVarClass::Copy(CBotVar* pSrc, bool bName) m_pClass = p->m_pClass; if ( p->m_pParent ) { - ASM_TRAP(); // "que faire du pParent"; + assert(0); // "que faire du pParent"; } // m_next = NULL; @@ -1768,7 +1770,7 @@ bool CBotVarClass::Ne(CBotVar* left, CBotVar* right) CBotVarArray::CBotVarArray(const CBotToken* name, CBotTypResult& type ) { if ( !type.Eq(CBotTypArrayPointer) && - !type.Eq(CBotTypArrayBody)) ASM_TRAP(); + !type.Eq(CBotTypArrayBody)) assert(0); m_token = new CBotToken(name); m_next = NULL; @@ -1791,7 +1793,7 @@ CBotVarArray::~CBotVarArray() void CBotVarArray::Copy(CBotVar* pSrc, bool bName) { if ( pSrc->GetType() != CBotTypArrayPointer ) - ASM_TRAP(); + assert(0); CBotVarArray* p = static_cast(pSrc); @@ -1825,7 +1827,7 @@ void CBotVarArray::SetPointer(CBotVar* pVarClass) if ( !pVarClass->m_type.Eq(CBotTypClass) && !pVarClass->m_type.Eq(CBotTypArrayBody)) - ASM_TRAP(); + assert(0); (static_cast(pVarClass))->IncrementUse(); // incement the reference } @@ -1882,7 +1884,7 @@ CBotVarPointer::CBotVarPointer(const CBotToken* name, CBotTypResult& type ) if ( !type.Eq(CBotTypPointer) && !type.Eq(CBotTypNullPointer) && !type.Eq(CBotTypClass) && // for convenience accepts Class and Intrinsic - !type.Eq(CBotTypIntrinsic) ) ASM_TRAP(); + !type.Eq(CBotTypIntrinsic) ) assert(0); m_token = new CBotToken(name); m_next = NULL; @@ -1965,7 +1967,7 @@ void CBotVarPointer::SetPointer(CBotVar* pVarClass) // if ( pVarClass->GetType() != CBotTypClass ) if ( !pVarClass->m_type.Eq(CBotTypClass) ) - ASM_TRAP(); + assert(0); (static_cast(pVarClass))->IncrementUse(); // increment the reference m_pClass = (static_cast(pVarClass))->m_pClass; @@ -2034,7 +2036,7 @@ void CBotVarPointer::Copy(CBotVar* pSrc, bool bName) { if ( pSrc->GetType() != CBotTypPointer && pSrc->GetType() != CBotTypNullPointer) - ASM_TRAP(); + assert(0); CBotVarPointer* p = static_cast(pSrc); @@ -2162,11 +2164,11 @@ int CBotTypResult::GetType(int mode) const m_type == CBotTypClass || m_type == CBotTypIntrinsic ) - if ( m_pClass == NULL ) ASM_TRAP(); + if ( m_pClass == NULL ) assert(0); if ( m_type == CBotTypArrayPointer ) - if ( m_pNext == NULL ) ASM_TRAP(); + if ( m_pNext == NULL ) assert(0); #endif if ( mode == 3 && m_type == CBotTypNullPointer ) return CBotTypPointer; return m_type; -- cgit v1.2.3-1-g7c22