Kaydet (Commit) f8ecdb76 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Simplify AstExpression::compare

...to only work with LONG values, as it is only used to compare enumerator
values.  (But keep its general defensive-programming air that's so prevalent
across the idlc code base; not sure whether it could rightfully be tightened, or
whether this might be needed in parser's error recovery.)

Change-Id: I15f1700834f9397f3c2e0ffdb00e2abeecb734f9
üst 187d7f8f
......@@ -114,8 +114,8 @@ public:
// Evaluate then store value inside this AstExpression
void evaluate();
// Compare to AstExpressions
bool compare(AstExpression *pExpr);
// Compare LONG AstExpression values
bool compareLong(AstExpression *pExpr);
OString toString();
private:
......
......@@ -43,7 +43,7 @@ AstConstant* AstEnum::checkValue(AstExpression* pExpr)
AstDeclaration* pDecl = *iter;
AstConstant* pConst = static_cast<AstConstant*>(pDecl);
if (pConst->getConstValue()->compare(pExpr))
if (pConst->getConstValue()->compareLong(pExpr))
return pConst;
++iter;
......
......@@ -758,7 +758,7 @@ bool AstExpression::coerce(ExprType t)
return m_exprValue != nullptr;
}
bool AstExpression::compare(AstExpression *pExpr)
bool AstExpression::compareLong(AstExpression *pExpr)
{
bool bRet = false;
if (m_combOperator != pExpr->getCombOperator())
......@@ -771,36 +771,9 @@ bool AstExpression::compare(AstExpression *pExpr)
return bRet;
switch (m_exprValue->et)
{
case ET_short:
bRet = m_exprValue->u.sval == pExpr->getExprValue()->u.sval;
break;
case ET_ushort:
bRet = m_exprValue->u.usval == pExpr->getExprValue()->u.usval;
break;
case ET_long:
bRet = m_exprValue->u.lval == pExpr->getExprValue()->u.lval;
break;
case ET_ulong:
bRet = m_exprValue->u.ulval == pExpr->getExprValue()->u.ulval;
break;
case ET_hyper:
bRet = m_exprValue->u.hval == pExpr->getExprValue()->u.hval;
break;
case ET_uhyper:
bRet = m_exprValue->u.uhval == pExpr->getExprValue()->u.uhval;
break;
case ET_float:
bRet = m_exprValue->u.fval == pExpr->getExprValue()->u.fval;
break;
case ET_double:
bRet = m_exprValue->u.dval == pExpr->getExprValue()->u.dval;
break;
case ET_byte:
bRet = m_exprValue->u.byval == pExpr->getExprValue()->u.byval;
break;
case ET_boolean:
bRet = m_exprValue->u.lval == pExpr->getExprValue()->u.lval;
break;
default:
OSL_ASSERT(false);
bRet = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment