summaryrefslogtreecommitdiff
path: root/idlc
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-10-06 16:36:26 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-10-06 16:36:26 +0200
commitf8ecdb7619cad29a6187004e28075efd928bd8aa (patch)
tree363be97a12e6f2dd38213f329b698692b333ebdc /idlc
parent187d7f8f527217c1f958feec7d3a83f866a8e477 (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')
-rw-r--r--idlc/inc/astexpression.hxx4
-rw-r--r--idlc/source/astenum.cxx2
-rw-r--r--idlc/source/astexpression.cxx29
3 files changed, 4 insertions, 31 deletions
diff --git a/idlc/inc/astexpression.hxx b/idlc/inc/astexpression.hxx
index ca060719ef2e..9bc1b9004409 100644
--- a/idlc/inc/astexpression.hxx
+++ b/idlc/inc/astexpression.hxx
@@ -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:
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;