diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-10-06 16:36:26 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-10-06 16:36:26 +0200 |
commit | f8ecdb7619cad29a6187004e28075efd928bd8aa (patch) | |
tree | 363be97a12e6f2dd38213f329b698692b333ebdc /idlc/source | |
parent | 187d7f8f527217c1f958feec7d3a83f866a8e477 (diff) |
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
Diffstat (limited to 'idlc/source')
-rw-r--r-- | idlc/source/astenum.cxx | 2 | ||||
-rw-r--r-- | idlc/source/astexpression.cxx | 29 |
2 files changed, 2 insertions, 29 deletions
diff --git a/idlc/source/astenum.cxx b/idlc/source/astenum.cxx index f006f611a8d4..ece9609a88d2 100644 --- a/idlc/source/astenum.cxx +++ b/idlc/source/astenum.cxx @@ -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; diff --git a/idlc/source/astexpression.cxx b/idlc/source/astexpression.cxx index 4e583b35e43c..0953c9bdbc3c 100644 --- a/idlc/source/astexpression.cxx +++ b/idlc/source/astexpression.cxx @@ -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; |