summaryrefslogtreecommitdiff
path: root/idlc
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-09-26 22:37:12 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-09-28 08:12:14 +0200
commit84001596c9ee3d616ba9f0afffb5b1e959278f6c (patch)
tree49f25cb70462099cdb2c47895c4763fb5e45f32b /idlc
parentb085d55e5546c94d4e6e0f8cb6ff6d9f28c9d2e6 (diff)
AstExpression::coerce always returned m_exprValue, so simplify its signature
Change-Id: I4fa380bc7e8d5b3581468cb0e6417b99587a1e9f
Diffstat (limited to 'idlc')
-rw-r--r--idlc/inc/idlc/astexpression.hxx4
-rw-r--r--idlc/source/astexpression.cxx26
2 files changed, 11 insertions, 19 deletions
diff --git a/idlc/inc/idlc/astexpression.hxx b/idlc/inc/idlc/astexpression.hxx
index 1bd6f96d6ec6..deb0da48d211 100644
--- a/idlc/inc/idlc/astexpression.hxx
+++ b/idlc/inc/idlc/astexpression.hxx
@@ -104,11 +104,9 @@ public:
{ return m_combOperator; }
AstExprValue* getExprValue()
{ return m_exprValue; }
- void setExprValue(AstExprValue *pEv)
- { m_exprValue = pEv; }
// Evaluation and value coercion
- AstExprValue* coerce(ExprType type);
+ bool coerce(ExprType type);
// Evaluate then store value inside this AstExpression
void evaluate();
diff --git a/idlc/source/astexpression.cxx b/idlc/source/astexpression.cxx
index c796ed530303..3927a3f888eb 100644
--- a/idlc/source/astexpression.cxx
+++ b/idlc/source/astexpression.cxx
@@ -685,7 +685,7 @@ coerce_value(AstExprValue *ev, ExprType t)
}
}
-AstExprValue* AstExpression::coerce(ExprType t)
+bool AstExpression::coerce(ExprType t)
{
AstExprValue *copy;
@@ -693,7 +693,7 @@ AstExprValue* AstExpression::coerce(ExprType t)
* Is it already of the right type?
*/
if (m_exprValue != NULL && m_exprValue->et == t)
- return m_exprValue;
+ return true;
/*
* OK, must coerce
*
@@ -702,7 +702,7 @@ AstExprValue* AstExpression::coerce(ExprType t)
*/
evaluate();
if (m_exprValue == NULL)
- return NULL;
+ return false;
/*
* Create a copy to contain coercion result
@@ -755,7 +755,7 @@ AstExprValue* AstExpression::coerce(ExprType t)
m_exprValue = copy;
- return copy;
+ return m_exprValue != nullptr;
}
bool AstExpression::operator==(AstExpression *pExpr)
@@ -919,14 +919,12 @@ AstExprValue* AstExpression::eval_bin_op()
m_subExpr1->evaluate();
if (m_subExpr1->getExprValue() == NULL)
return NULL;
- m_subExpr1->setExprValue(m_subExpr1->coerce(eType));
- if (m_subExpr1->getExprValue() == NULL)
+ if (!m_subExpr1->coerce(eType))
return NULL;
m_subExpr2->evaluate();
if (m_subExpr2->getExprValue() == NULL)
return NULL;
- m_subExpr2->setExprValue(m_subExpr2->coerce(eType));
- if (m_subExpr2->getExprValue() == NULL)
+ if (!m_subExpr2->coerce(eType))
return NULL;
std::unique_ptr< AstExprValue > retval(new AstExprValue());
@@ -967,14 +965,12 @@ AstExprValue* AstExpression::eval_bit_op()
m_subExpr1->evaluate();
if (m_subExpr1->getExprValue() == NULL)
return NULL;
- m_subExpr1->setExprValue(m_subExpr1->coerce(ET_long));
- if (m_subExpr1->getExprValue() == NULL)
+ if (!m_subExpr1->coerce(ET_long))
return NULL;
m_subExpr2->evaluate();
if (m_subExpr2->getExprValue() == NULL)
return NULL;
- m_subExpr2->setExprValue(m_subExpr2->coerce(ET_long));
- if (m_subExpr2->getExprValue() == NULL)
+ if (!m_subExpr2->coerce(ET_long))
return NULL;
std::unique_ptr< AstExprValue > retval(new AstExprValue());
@@ -1014,8 +1010,7 @@ AstExprValue* AstExpression::eval_un_op()
m_subExpr1->evaluate();
if (m_subExpr1->getExprValue() == NULL)
return NULL;
- m_subExpr1->setExprValue(m_subExpr1->coerce(ET_double));
- if (m_subExpr1->getExprValue() == NULL)
+ if (!m_subExpr1->coerce(ET_double))
return NULL;
std::unique_ptr< AstExprValue > retval(new AstExprValue());
@@ -1030,8 +1025,7 @@ AstExprValue* AstExpression::eval_un_op()
retval->u.lval = -(m_subExpr1->getExprValue()->u.lval);
break;
case EC_bit_neg:
- m_subExpr1->setExprValue(m_subExpr1->coerce(ET_long));
- if (m_subExpr1->getExprValue() == NULL)
+ if (!m_subExpr1->coerce(ET_long))
return NULL;
retval->u.lval = ~m_subExpr1->getExprValue()->u.lval;
break;