Use Q_ASSERT marcros instead MUP_ASSERT and MUP_FAIL.

--HG--
branch : feature
This commit is contained in:
dismine 2014-04-25 18:10:56 +03:00
parent 11f527143b
commit 2f97def4bf
2 changed files with 11 additions and 40 deletions

View File

@ -873,13 +873,13 @@ namespace qmu
while (a_stOpt.size() && a_stOpt.top().GetCode()==cmELSE) while (a_stOpt.size() && a_stOpt.top().GetCode()==cmELSE)
{ {
token_type opElse = a_stOpt.pop(); token_type opElse = a_stOpt.pop();
MUP_ASSERT(a_stOpt.size()>0); Q_ASSERT(a_stOpt.size()>0);
// Take the value associated with the else branch from the value stack // Take the value associated with the else branch from the value stack
token_type vVal2 = a_stVal.pop(); token_type vVal2 = a_stVal.pop();
MUP_ASSERT(a_stOpt.size()>0); Q_ASSERT(a_stOpt.size()>0);
MUP_ASSERT(a_stVal.size()>=2); Q_ASSERT(a_stVal.size()>=2);
// it then else is a ternary operator Pop all three values from the value s // it then else is a ternary operator Pop all three values from the value s
// tack and just return the right value // tack and just return the right value
@ -889,8 +889,8 @@ namespace qmu
a_stVal.push( (vExpr.GetVal()!=0) ? vVal1 : vVal2); a_stVal.push( (vExpr.GetVal()!=0) ? vVal1 : vVal2);
token_type opIf = a_stOpt.pop(); token_type opIf = a_stOpt.pop();
MUP_ASSERT(opElse.GetCode()==cmELSE); Q_ASSERT(opElse.GetCode()==cmELSE);
MUP_ASSERT(opIf.GetCode()==cmIF); Q_ASSERT(opIf.GetCode()==cmIF);
m_vRPN.AddIfElse(cmENDIF); m_vRPN.AddIfElse(cmENDIF);
} // while pending if-else-clause found } // while pending if-else-clause found
@ -910,7 +910,7 @@ namespace qmu
} }
else else
{ {
MUP_ASSERT(a_stVal.size()>=2); Q_ASSERT(a_stVal.size()>=2);
token_type valTok1 = a_stVal.pop(), token_type valTok1 = a_stVal.pop(),
valTok2 = a_stVal.pop(), valTok2 = a_stVal.pop(),
optTok = a_stOpt.pop(), optTok = a_stOpt.pop(),
@ -1044,7 +1044,7 @@ namespace qmu
//case cmBO: // unused, listed for compiler optimization purposes //case cmBO: // unused, listed for compiler optimization purposes
//case cmBC: //case cmBC:
// MUP_FAIL(INVALID_CODE_IN_BYTECODE); // Q_ASSERT(INVALID_CODE_IN_BYTECODE);
// continue; // continue;
case cmIF: case cmIF:
@ -1060,7 +1060,7 @@ namespace qmu
continue; continue;
//case cmARG_SEP: //case cmARG_SEP:
// MUP_FAIL(INVALID_CODE_IN_BYTECODE); // Q_ASSERT(INVALID_CODE_IN_BYTECODE);
// continue; // continue;
// value and variable tokens // value and variable tokens
@ -1118,7 +1118,7 @@ namespace qmu
// The index of the string argument in the string table // The index of the string argument in the string table
int iIdxStack = pTok->Fun.idx; int iIdxStack = pTok->Fun.idx;
MUP_ASSERT( iIdxStack>=0 && iIdxStack<(int)m_vStringBuf.size() ); Q_ASSERT( iIdxStack>=0 && iIdxStack<(int)m_vStringBuf.size() );
switch(pTok->Fun.argc) // switch according to argument count switch(pTok->Fun.argc) // switch according to argument count
{ {
@ -1158,7 +1158,7 @@ namespace qmu
//case cmOPRT_BIN: //case cmOPRT_BIN:
//case cmOPRT_POSTFIX: //case cmOPRT_POSTFIX:
//case cmOPRT_INFIX: //case cmOPRT_INFIX:
// MUP_FAIL(INVALID_CODE_IN_BYTECODE); // Q_ASSERT(INVALID_CODE_IN_BYTECODE);
// continue; // continue;
//case cmEND: //case cmEND:
@ -1392,7 +1392,7 @@ namespace qmu
Error(ecMISSING_ELSE_CLAUSE); Error(ecMISSING_ELSE_CLAUSE);
// get the last value (= final result) from the stack // get the last value (= final result) from the stack
MUP_ASSERT(stArgCount.size()==1); Q_ASSERT(stArgCount.size()==1);
m_nFinalResultIdx = stArgCount.top(); m_nFinalResultIdx = stArgCount.top();
if (m_nFinalResultIdx==0) if (m_nFinalResultIdx==0)
Error(ecINTERNAL_ERROR, 9); Error(ecINTERNAL_ERROR, 9);

View File

@ -58,35 +58,6 @@
#define MUP_STRING_TYPE std::string #define MUP_STRING_TYPE std::string
#endif #endif
#if defined(_DEBUG)
/** \brief Debug macro to force an abortion of the programm with a certain message.
*/
#define MUP_FAIL(MSG) \
{ \
bool MSG=false; \
assert(MSG); \
}
/** \brief An assertion that does not kill the program.
This macro is neutralised in UNICODE builds. It's
too difficult to translate.
*/
#define MUP_ASSERT(COND) \
if (!(COND)) \
{ \
stringstream_type ss; \
ss << "Assertion \"" #COND "\" failed: ") \
<< __FILE__ << " line " \
<< __LINE__ << "."; \
throw ParserError( ss.str() ); \
}
#else
#define MUP_FAIL(MSG)
#define MUP_ASSERT(COND)
#endif
namespace qmu namespace qmu
{ {
#if defined(_UNICODE) #if defined(_UNICODE)