delete Q_UNREACHABLE().

--HG--
branch : feature
This commit is contained in:
dismine 2014-05-06 13:51:14 +03:00
parent 3c8338faae
commit 2e6cc94e19
2 changed files with 22 additions and 409 deletions

View File

@ -375,107 +375,39 @@ void QmuParserBase::CheckOprt(const QString &a_sName, const QmuParserCallback &a
Error(ecINVALID_INFIX_IDENT, -1, a_sName); Error(ecINVALID_INFIX_IDENT, -1, a_sName);
break; break;
case cmLE: case cmLE:
Q_UNREACHABLE();
break;
case cmGE: case cmGE:
Q_UNREACHABLE();
break;
case cmNEQ: case cmNEQ:
Q_UNREACHABLE();
break;
case cmEQ: case cmEQ:
Q_UNREACHABLE();
break;
case cmLT: case cmLT:
Q_UNREACHABLE();
break;
case cmGT: case cmGT:
Q_UNREACHABLE();
break;
case cmADD: case cmADD:
Q_UNREACHABLE();
break;
case cmSUB: case cmSUB:
Q_UNREACHABLE();
break;
case cmMUL: case cmMUL:
Q_UNREACHABLE();
break;
case cmDIV: case cmDIV:
Q_UNREACHABLE();
break;
case cmPOW: case cmPOW:
Q_UNREACHABLE();
break;
case cmLAND: case cmLAND:
Q_UNREACHABLE();
break;
case cmLOR: case cmLOR:
Q_UNREACHABLE();
break;
case cmASSIGN: case cmASSIGN:
Q_UNREACHABLE();
break;
case cmBO: case cmBO:
Q_UNREACHABLE();
break;
case cmBC: case cmBC:
Q_UNREACHABLE();
break;
case cmIF: case cmIF:
Q_UNREACHABLE();
break;
case cmELSE: case cmELSE:
Q_UNREACHABLE();
break;
case cmENDIF: case cmENDIF:
Q_UNREACHABLE();
break;
case cmARG_SEP: case cmARG_SEP:
Q_UNREACHABLE();
break;
case cmVAR: case cmVAR:
Q_UNREACHABLE();
break;
case cmVAL: case cmVAL:
Q_UNREACHABLE();
break;
case cmVARPOW2: case cmVARPOW2:
// For optimization purposes
break;
case cmVARPOW3: case cmVARPOW3:
// For optimization purposes
break;
case cmVARPOW4: case cmVARPOW4:
// For optimization purposes
break;
case cmVARMUL: case cmVARMUL:
// For optimization purposes
break;
case cmPOW2: case cmPOW2:
// For optimization purposes
break;
case cmFUNC: case cmFUNC:
Q_UNREACHABLE();
break;
case cmFUNC_STR: case cmFUNC_STR:
Q_UNREACHABLE();
break;
case cmFUNC_BULK: case cmFUNC_BULK:
Q_UNREACHABLE();
break;
case cmSTRING: case cmSTRING:
Q_UNREACHABLE();
break;
case cmOPRT_BIN: case cmOPRT_BIN:
Q_UNREACHABLE();
break;
case cmEND: case cmEND:
Q_UNREACHABLE();
break;
case cmUNKNOWN: case cmUNKNOWN:
Q_UNREACHABLE();
break;
default: default:
Error(ecINVALID_NAME, -1, a_sName); Error(ecINVALID_NAME, -1, a_sName);
break; break;
@ -778,53 +710,21 @@ int QmuParserBase::GetOprtPrecedence(const token_type &a_Tok) const
case cmOPRT_BIN: case cmOPRT_BIN:
return a_Tok.GetPri(); return a_Tok.GetPri();
case cmBO: case cmBO:
Q_UNREACHABLE();
break;
case cmBC: case cmBC:
Q_UNREACHABLE();
break;
case cmENDIF: case cmENDIF:
Q_UNREACHABLE();
break;
case cmVAR: case cmVAR:
Q_UNREACHABLE();
break;
case cmVAL: case cmVAL:
Q_UNREACHABLE();
break;
case cmVARPOW2: case cmVARPOW2:
Q_UNREACHABLE();
break;
case cmVARPOW3: case cmVARPOW3:
Q_UNREACHABLE();
break;
case cmVARPOW4: case cmVARPOW4:
Q_UNREACHABLE();
break;
case cmVARMUL: case cmVARMUL:
Q_UNREACHABLE();
break;
case cmPOW2: case cmPOW2:
Q_UNREACHABLE();
break;
case cmFUNC: case cmFUNC:
Q_UNREACHABLE();
break;
case cmFUNC_STR: case cmFUNC_STR:
Q_UNREACHABLE();
break;
case cmFUNC_BULK: case cmFUNC_BULK:
Q_UNREACHABLE();
break;
case cmSTRING: case cmSTRING:
Q_UNREACHABLE();
break;
case cmOPRT_POSTFIX: case cmOPRT_POSTFIX:
Q_UNREACHABLE();
break;
case cmUNKNOWN: case cmUNKNOWN:
Q_UNREACHABLE();
break;
default: default:
Error(ecINTERNAL_ERROR, 5); Error(ecINTERNAL_ERROR, 5);
return 999; return 999;
@ -859,68 +759,26 @@ EOprtAssociativity QmuParserBase::GetOprtAssociativity(const token_type &a_Tok)
case cmOPRT_BIN: case cmOPRT_BIN:
return a_Tok.GetAssociativity(); return a_Tok.GetAssociativity();
case cmBO: case cmBO:
Q_UNREACHABLE();
break;
case cmBC: case cmBC:
Q_UNREACHABLE();
break;
case cmIF: case cmIF:
Q_UNREACHABLE();
break;
case cmELSE: case cmELSE:
Q_UNREACHABLE();
break;
case cmENDIF: case cmENDIF:
Q_UNREACHABLE();
break;
case cmARG_SEP: case cmARG_SEP:
Q_UNREACHABLE();
break;
case cmVAR: case cmVAR:
Q_UNREACHABLE();
break;
case cmVAL: case cmVAL:
Q_UNREACHABLE();
break;
case cmVARPOW2: case cmVARPOW2:
Q_UNREACHABLE();
break;
case cmVARPOW3: case cmVARPOW3:
Q_UNREACHABLE();
break;
case cmVARPOW4: case cmVARPOW4:
Q_UNREACHABLE();
break;
case cmVARMUL: case cmVARMUL:
Q_UNREACHABLE();
break;
case cmPOW2: case cmPOW2:
Q_UNREACHABLE();
break;
case cmFUNC: case cmFUNC:
Q_UNREACHABLE();
break;
case cmFUNC_STR: case cmFUNC_STR:
Q_UNREACHABLE();
break;
case cmFUNC_BULK: case cmFUNC_BULK:
Q_UNREACHABLE();
break;
case cmSTRING: case cmSTRING:
Q_UNREACHABLE();
break;
case cmOPRT_POSTFIX: case cmOPRT_POSTFIX:
Q_UNREACHABLE();
break;
case cmOPRT_INFIX: case cmOPRT_INFIX:
Q_UNREACHABLE();
break;
case cmEND: case cmEND:
Q_UNREACHABLE();
break;
case cmUNKNOWN: case cmUNKNOWN:
Q_UNREACHABLE();
break;
default: default:
return oaNONE; return oaNONE;
} }
@ -1352,62 +1210,24 @@ void QmuParserBase::ApplyRemainingOprt(QStack<token_type> &stOpt, QStack<token_t
ApplyIfElse(stOpt, stVal); ApplyIfElse(stOpt, stVal);
break; break;
case cmBO: case cmBO:
Q_UNREACHABLE();
break;
case cmBC: case cmBC:
Q_UNREACHABLE();
break;
case cmIF: case cmIF:
Q_UNREACHABLE();
break;
case cmENDIF: case cmENDIF:
Q_UNREACHABLE();
break;
case cmARG_SEP: case cmARG_SEP:
Q_UNREACHABLE();
break;
case cmVAR: case cmVAR:
Q_UNREACHABLE();
break;
case cmVAL: case cmVAL:
Q_UNREACHABLE();
break;
case cmVARPOW2: case cmVARPOW2:
Q_UNREACHABLE();
break;
case cmVARPOW3: case cmVARPOW3:
Q_UNREACHABLE();
break;
case cmVARPOW4: case cmVARPOW4:
Q_UNREACHABLE();
break;
case cmVARMUL: case cmVARMUL:
Q_UNREACHABLE();
break;
case cmPOW2: case cmPOW2:
Q_UNREACHABLE();
break;
case cmFUNC: case cmFUNC:
Q_UNREACHABLE();
break;
case cmFUNC_STR: case cmFUNC_STR:
Q_UNREACHABLE();
break;
case cmFUNC_BULK: case cmFUNC_BULK:
Q_UNREACHABLE();
break;
case cmSTRING: case cmSTRING:
Q_UNREACHABLE();
break;
case cmOPRT_POSTFIX: case cmOPRT_POSTFIX:
Q_UNREACHABLE();
break;
case cmEND: case cmEND:
Q_UNREACHABLE();
break;
case cmUNKNOWN: case cmUNKNOWN:
Q_UNREACHABLE();
break;
default: default:
Error(ecINTERNAL_ERROR); Error(ecINTERNAL_ERROR);
break; break;
@ -1525,14 +1345,6 @@ qreal QmuParserBase::ParseCmdCodeBulk(int nOffset, int nThreadID) const
--sidx; --sidx;
Stack[sidx] = *pTok->Oprt.ptr = Stack[sidx+1]; Stack[sidx] = *pTok->Oprt.ptr = Stack[sidx+1];
continue; continue;
case cmBO: // unused, listed for compiler optimization purposes
Q_UNREACHABLE();
break;
case cmBC:
Q_UNREACHABLE();
break;
// Q_ASSERT(INVALID_CODE_IN_BYTECODE);
// continue;
case cmIF: case cmIF:
if (qFuzzyCompare(Stack[sidx--]+1, 1+0)) if (qFuzzyCompare(Stack[sidx--]+1, 1+0))
{ {
@ -1544,11 +1356,6 @@ qreal QmuParserBase::ParseCmdCodeBulk(int nOffset, int nThreadID) const
continue; continue;
case cmENDIF: case cmENDIF:
continue; continue;
case cmARG_SEP:
Q_UNREACHABLE();
break;
// Q_ASSERT(INVALID_CODE_IN_BYTECODE);
// continue;
// value and variable tokens // value and variable tokens
case cmVAR: case cmVAR:
@ -1747,29 +1554,22 @@ qreal QmuParserBase::ParseCmdCodeBulk(int nOffset, int nThreadID) const
} }
} }
case cmSTRING: case cmSTRING:
Q_UNREACHABLE();
break;
case cmOPRT_BIN: case cmOPRT_BIN:
Q_UNREACHABLE();
break;
case cmOPRT_POSTFIX: case cmOPRT_POSTFIX:
Q_UNREACHABLE();
break;
case cmOPRT_INFIX: case cmOPRT_INFIX:
Q_UNREACHABLE();
break;
// Q_ASSERT(INVALID_CODE_IN_BYTECODE); // Q_ASSERT(INVALID_CODE_IN_BYTECODE);
// continue; // continue;
case cmEND: case cmEND:
Q_UNREACHABLE();
break;
// return Stack[m_nFinalResultIdx]; // return Stack[m_nFinalResultIdx];
case cmPOW2: case cmPOW2:
Q_UNREACHABLE();
break;
case cmUNKNOWN: case cmUNKNOWN:
Q_UNREACHABLE(); case cmBO: // unused, listed for compiler optimization purposes
break; case cmBC:
// Q_ASSERT(INVALID_CODE_IN_BYTECODE);
// continue;
case cmARG_SEP:
// Q_ASSERT(INVALID_CODE_IN_BYTECODE);
// continue;
default: default:
Error(ecINTERNAL_ERROR, 3); Error(ecINTERNAL_ERROR, 3);
return 0; return 0;
@ -1967,26 +1767,12 @@ void QmuParserBase::CreateRPN() const
ApplyFunc(stOpt, stVal, 1); // this is the postfix operator ApplyFunc(stOpt, stVal, 1); // this is the postfix operator
break; break;
case cmENDIF: case cmENDIF:
Q_UNREACHABLE();
break;
case cmVARPOW2: case cmVARPOW2:
Q_UNREACHABLE();
break;
case cmVARPOW3: case cmVARPOW3:
Q_UNREACHABLE();
break;
case cmVARPOW4: case cmVARPOW4:
Q_UNREACHABLE();
break;
case cmVARMUL: case cmVARMUL:
Q_UNREACHABLE();
break;
case cmPOW2: case cmPOW2:
Q_UNREACHABLE();
break;
case cmUNKNOWN: case cmUNKNOWN:
Q_UNREACHABLE();
break;
default: default:
Error(ecINTERNAL_ERROR, 3); Error(ecINTERNAL_ERROR, 3);
} // end of switch operator-token } // end of switch operator-token
@ -2326,71 +2112,27 @@ void QmuParserBase::StackDump(const QStack<token_type> &a_stVal, const QStack<to
qDebug() << "ENDIF\n"; qDebug() << "ENDIF\n";
break; break;
case cmLE: case cmLE:
Q_UNREACHABLE();
break;
case cmGE: case cmGE:
Q_UNREACHABLE();
break;
case cmNEQ: case cmNEQ:
Q_UNREACHABLE();
break;
case cmEQ: case cmEQ:
Q_UNREACHABLE();
break;
case cmLT: case cmLT:
Q_UNREACHABLE();
break;
case cmGT: case cmGT:
Q_UNREACHABLE();
break;
case cmADD: case cmADD:
Q_UNREACHABLE();
break;
case cmSUB: case cmSUB:
Q_UNREACHABLE();
break;
case cmMUL: case cmMUL:
Q_UNREACHABLE();
break;
case cmDIV: case cmDIV:
Q_UNREACHABLE();
break;
case cmPOW: case cmPOW:
Q_UNREACHABLE();
break;
case cmLAND: case cmLAND:
Q_UNREACHABLE();
break;
case cmLOR: case cmLOR:
Q_UNREACHABLE();
break;
case cmASSIGN: case cmASSIGN:
Q_UNREACHABLE();
break;
case cmARG_SEP: case cmARG_SEP:
Q_UNREACHABLE();
break;
case cmVARPOW2: case cmVARPOW2:
Q_UNREACHABLE();
break;
case cmVARPOW3: case cmVARPOW3:
Q_UNREACHABLE();
break;
case cmVARPOW4: case cmVARPOW4:
Q_UNREACHABLE();
break;
case cmVARMUL: case cmVARMUL:
Q_UNREACHABLE();
break;
case cmPOW2: case cmPOW2:
Q_UNREACHABLE();
break;
case cmSTRING: case cmSTRING:
Q_UNREACHABLE();
break;
case cmOPRT_POSTFIX: case cmOPRT_POSTFIX:
Q_UNREACHABLE();
break;
default: default:
qDebug() << stOprt.top().GetCode() << " "; qDebug() << stOprt.top().GetCode() << " ";
break; break;

View File

@ -202,7 +202,7 @@ void QmuParserByteCode::ConstantFolding(ECmdCode a_Oprt)
#if defined(MUP_MATH_EXCEPTIONS) #if defined(MUP_MATH_EXCEPTIONS)
if (y==0) if (y==0)
{ {
throw ParserError(ecDIV_BY_ZERO, "0"); throw qmuParserError(ecDIV_BY_ZERO, "0");
} }
#endif #endif
x = x / y; x = x / y;
@ -419,104 +419,47 @@ void QmuParserByteCode::AddOp(ECmdCode a_Oprt)
} }
break; break;
case cmDIV: case cmDIV:
if (m_vRPN[sz-1].Cmd == cmVAL && m_vRPN[sz-2].Cmd == cmVARMUL && if (m_vRPN[sz-1].Cmd == cmVAL && m_vRPN[sz-2].Cmd == cmVARMUL &&
(qFuzzyCompare(m_vRPN[sz-1].Val.data2+1, 1+0)==false)) (qFuzzyCompare(m_vRPN[sz-1].Val.data2+1, 1+0)==false))
{ {
// Optimization: 4*a/2 -> 2*a // Optimization: 4*a/2 -> 2*a
m_vRPN[sz-2].Val.data /= m_vRPN[sz-1].Val.data2; m_vRPN[sz-2].Val.data /= m_vRPN[sz-1].Val.data2;
m_vRPN[sz-2].Val.data2 /= m_vRPN[sz-1].Val.data2; m_vRPN[sz-2].Val.data2 /= m_vRPN[sz-1].Val.data2;
m_vRPN.pop_back(); m_vRPN.pop_back();
bOptimized = true; bOptimized = true;
} }
break;
case cmLE:
break;
case cmGE:
break; break;
case cmNEQ: case cmNEQ:
Q_UNREACHABLE();
break;
case cmEQ: case cmEQ:
Q_UNREACHABLE();
break;
case cmLT:
break;
case cmGT:
break;
case cmLAND:
break;
case cmLOR: case cmLOR:
Q_UNREACHABLE();
break;
case cmASSIGN: case cmASSIGN:
Q_UNREACHABLE();
break;
case cmBO: case cmBO:
Q_UNREACHABLE();
break;
case cmBC: case cmBC:
Q_UNREACHABLE();
break;
case cmIF: case cmIF:
Q_UNREACHABLE();
break;
case cmELSE: case cmELSE:
Q_UNREACHABLE();
break;
case cmENDIF: case cmENDIF:
Q_UNREACHABLE();
break;
case cmARG_SEP: case cmARG_SEP:
Q_UNREACHABLE();
break;
case cmVAR: case cmVAR:
Q_UNREACHABLE();
break;
case cmVAL: case cmVAL:
Q_UNREACHABLE();
break;
case cmVARPOW2: case cmVARPOW2:
Q_UNREACHABLE();
break;
case cmVARPOW3: case cmVARPOW3:
Q_UNREACHABLE();
break;
case cmVARPOW4: case cmVARPOW4:
Q_UNREACHABLE();
break;
case cmVARMUL: case cmVARMUL:
Q_UNREACHABLE();
break;
case cmPOW2: case cmPOW2:
Q_UNREACHABLE();
break;
case cmFUNC: case cmFUNC:
Q_UNREACHABLE();
break;
case cmFUNC_STR: case cmFUNC_STR:
Q_UNREACHABLE();
break;
case cmFUNC_BULK: case cmFUNC_BULK:
Q_UNREACHABLE();
break;
case cmSTRING: case cmSTRING:
Q_UNREACHABLE();
break;
case cmOPRT_BIN: case cmOPRT_BIN:
Q_UNREACHABLE();
break;
case cmOPRT_POSTFIX: case cmOPRT_POSTFIX:
Q_UNREACHABLE();
break;
case cmOPRT_INFIX: case cmOPRT_INFIX:
Q_UNREACHABLE();
break;
case cmEND: case cmEND:
Q_UNREACHABLE();
break;
case cmUNKNOWN: case cmUNKNOWN:
Q_UNREACHABLE(); case cmLE:
break; case cmGE:
case cmLT:
case cmGT:
case cmLAND:
default: default:
break; break;
@ -665,88 +608,38 @@ void QmuParserByteCode::Finalize() Q_DECL_NOEXCEPT
m_vRPN[idx].Oprt.offset = i - idx; m_vRPN[idx].Oprt.offset = i - idx;
break; break;
case cmLE: case cmLE:
break;
case cmGE: case cmGE:
break;
case cmNEQ: case cmNEQ:
Q_UNREACHABLE();
break;
case cmEQ: case cmEQ:
Q_UNREACHABLE();
break;
case cmLT: case cmLT:
break;
case cmGT: case cmGT:
break;
case cmADD: case cmADD:
break;
case cmSUB: case cmSUB:
break;
case cmMUL: case cmMUL:
break;
case cmDIV: case cmDIV:
break;
case cmPOW: case cmPOW:
break;
case cmLAND: case cmLAND:
break;
case cmLOR: case cmLOR:
Q_UNREACHABLE();
break;
case cmASSIGN: case cmASSIGN:
break;
case cmBO: case cmBO:
Q_UNREACHABLE();
break;
case cmBC: case cmBC:
Q_UNREACHABLE();
break;
case cmARG_SEP: case cmARG_SEP:
Q_UNREACHABLE();
break;
case cmVAR: case cmVAR:
break;
case cmVAL: case cmVAL:
break;
case cmVARPOW2: case cmVARPOW2:
// For optimization purposes
break;
case cmVARPOW3: case cmVARPOW3:
// For optimization purposes
break;
case cmVARPOW4: case cmVARPOW4:
// For optimization purposes
break;
case cmVARMUL: case cmVARMUL:
// For optimization purposes
break;
case cmPOW2: case cmPOW2:
// For optimization purposes
break;
case cmFUNC: case cmFUNC:
break;
case cmFUNC_STR: case cmFUNC_STR:
break;
case cmFUNC_BULK: case cmFUNC_BULK:
Q_UNREACHABLE();
break;
case cmSTRING: case cmSTRING:
Q_UNREACHABLE();
break;
case cmOPRT_BIN: case cmOPRT_BIN:
Q_UNREACHABLE();
break;
case cmOPRT_POSTFIX: case cmOPRT_POSTFIX:
Q_UNREACHABLE();
break;
case cmOPRT_INFIX: case cmOPRT_INFIX:
Q_UNREACHABLE();
break;
case cmEND: case cmEND:
break;
case cmUNKNOWN: case cmUNKNOWN:
Q_UNREACHABLE();
break;
default: default:
break; break;
} }
@ -894,38 +787,16 @@ void QmuParserByteCode::AsciiDump()
qDebug() << "ASSIGN\t" << "[ADDR: 0x" << QString::number(*m_vRPN[i].Oprt.ptr, 'f', 16) << "]\n"; qDebug() << "ASSIGN\t" << "[ADDR: 0x" << QString::number(*m_vRPN[i].Oprt.ptr, 'f', 16) << "]\n";
break; break;
case cmBO: case cmBO:
Q_UNREACHABLE();
break;
case cmBC: case cmBC:
Q_UNREACHABLE();
break;
case cmARG_SEP: case cmARG_SEP:
Q_UNREACHABLE();
break;
case cmPOW2: case cmPOW2:
Q_UNREACHABLE();
break;
case cmFUNC_BULK: case cmFUNC_BULK:
Q_UNREACHABLE();
break;
case cmSTRING: case cmSTRING:
Q_UNREACHABLE();
break;
case cmOPRT_BIN: case cmOPRT_BIN:
Q_UNREACHABLE();
break;
case cmOPRT_POSTFIX: case cmOPRT_POSTFIX:
Q_UNREACHABLE();
break;
case cmOPRT_INFIX: case cmOPRT_INFIX:
Q_UNREACHABLE();
break;
case cmEND: case cmEND:
Q_UNREACHABLE();
break;
case cmUNKNOWN: case cmUNKNOWN:
Q_UNREACHABLE();
break;
default: default:
qDebug() << "(unknown code: " << m_vRPN[i].Cmd << ")\n"; qDebug() << "(unknown code: " << m_vRPN[i].Cmd << ")\n";
break; break;