[Libreoffice-commits] core.git: idlc/inc idlc/source
Stephan Bergmann
sbergman at redhat.com
Thu Oct 6 14:56:06 UTC 2016
idlc/inc/astexpression.hxx | 4 ++--
idlc/source/astenum.cxx | 2 +-
idlc/source/astexpression.cxx | 29 +----------------------------
3 files changed, 4 insertions(+), 31 deletions(-)
New commits:
commit f8ecdb7619cad29a6187004e28075efd928bd8aa
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Oct 6 16:36:26 2016 +0200
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
diff --git a/idlc/inc/astexpression.hxx b/idlc/inc/astexpression.hxx
index ca060719..9bc1b90 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 f006f61..ece9609 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 4e583b3..0953c9b 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;
More information about the Libreoffice-commits
mailing list