summaryrefslogtreecommitdiff
path: root/idlc
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-09-26 21:54:07 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-09-26 21:54:07 +0200
commitbc1fdb79b0a7eba791bf7f5749a8a45ad6a94bff (patch)
tree32cbc6c06e730efac4ab325fcda5ca48480a8dc6 /idlc
parent6dbc69bdf44f1933687b93b4c1838b57804ecc17 (diff)
The only EvalKind actually used is EK_const
Change-Id: Ide451d1e287eeb8666b9ddcce312b9a753761c50
Diffstat (limited to 'idlc')
-rw-r--r--idlc/inc/idlc/astexpression.hxx19
-rw-r--r--idlc/source/astexpression.cxx79
-rw-r--r--idlc/source/parser.y2
3 files changed, 34 insertions, 66 deletions
diff --git a/idlc/inc/idlc/astexpression.hxx b/idlc/inc/idlc/astexpression.hxx
index 1e38895fd1ee..327cbe9803c9 100644
--- a/idlc/inc/idlc/astexpression.hxx
+++ b/idlc/inc/idlc/astexpression.hxx
@@ -41,13 +41,6 @@ enum ExprComb
EC_symbol // a symbol (function or constant name)
};
-// Enum to define the different kinds of evaluation possible
-enum EvalKind
-{
- EK_const, // Must evaluate to constant
- EK_positive_int // Must evaluate to positive integer
-};
-
// Enum to define expression type
enum ExprType
{
@@ -118,7 +111,7 @@ public:
AstExprValue* coerce(ExprType type, bool bAssign=true);
// Evaluate then store value inside this AstExpression
- void evaluate(EvalKind ek);
+ void evaluate();
// Compare to AstExpressions
bool operator==(AstExpression *pExpr);
@@ -129,12 +122,12 @@ private:
// Fill out the lineno, filename and definition scope details
void fillDefinitionDetails();
// Internal evaluation
- AstExprValue* eval_internal(EvalKind ek);
+ AstExprValue* eval_internal();
// Evaluate different sets of operators
- AstExprValue* eval_bin_op(EvalKind ek);
- AstExprValue* eval_bit_op(EvalKind ek);
- AstExprValue* eval_un_op(EvalKind ek);
- AstExprValue* eval_symbol(EvalKind ek);
+ AstExprValue* eval_bin_op();
+ AstExprValue* eval_bit_op();
+ AstExprValue* eval_un_op();
+ AstExprValue* eval_symbol();
AstScope* m_pScope; // scope defined in
sal_Int32 m_lineNo; // line number defined in
diff --git a/idlc/source/astexpression.cxx b/idlc/source/astexpression.cxx
index ceda954a53d2..3bde39121599 100644
--- a/idlc/source/astexpression.cxx
+++ b/idlc/source/astexpression.cxx
@@ -685,24 +685,6 @@ coerce_value(AstExprValue *ev, ExprType t)
}
}
-/*
- * Evaluate the expression with the evaluation kind requested. Supported
- * evaluation kinds are
- * - EK_const: The expression must evaluate to a constant
- * - EK_positive_int: The expression must further evaluate to a
- * positive integer
- */
-static AstExprValue *
-eval_kind(AstExprValue *ev, EvalKind ek)
-{
- if (ek == EK_const)
- return ev;
- if (ek == EK_positive_int)
- return coerce_value(ev, ET_ulong);
-
- return NULL;
-}
-
AstExprValue* AstExpression::coerce(ExprType t, bool bAssign)
{
AstExprValue *copy;
@@ -718,7 +700,7 @@ AstExprValue* AstExpression::coerce(ExprType t, bool bAssign)
* First, evaluate it, then try to coerce result type
* If already evaluated, return the result
*/
- m_exprValue = eval_internal(EK_const);
+ m_exprValue = eval_internal();
if (m_exprValue == NULL)
return NULL;
@@ -775,10 +757,9 @@ AstExprValue* AstExpression::coerce(ExprType t, bool bAssign)
return coerced;
}
-void AstExpression::evaluate(EvalKind ek)
+void AstExpression::evaluate()
{
- m_exprValue = eval_internal(ek);
- m_exprValue = eval_kind(m_exprValue, ek);
+ m_exprValue = eval_internal();
}
bool AstExpression::operator==(AstExpression *pExpr)
@@ -786,8 +767,8 @@ bool AstExpression::operator==(AstExpression *pExpr)
bool bRet = false;
if (m_combOperator != pExpr->getCombOperator())
return bRet;
- evaluate(EK_const);
- pExpr->evaluate(EK_const);
+ evaluate();
+ pExpr->evaluate();
if (m_exprValue == NULL || pExpr->getExprValue() == NULL)
return bRet;
if (m_exprValue->et != pExpr->getExprValue()->et)
@@ -838,8 +819,8 @@ bool AstExpression::compare(AstExpression *pExpr)
bool bRet = false;
if (m_combOperator != pExpr->getCombOperator())
return bRet;
- evaluate(EK_const);
- pExpr->evaluate(EK_const);
+ evaluate();
+ pExpr->evaluate();
if (m_exprValue == NULL || pExpr->getExprValue() == NULL)
return bRet;
if (m_exprValue->et != pExpr->getExprValue()->et)
@@ -891,13 +872,13 @@ void AstExpression::fillDefinitionDetails()
m_fileName = idlc()->getFileName();
}
-AstExprValue* AstExpression::eval_internal(EvalKind ek)
+AstExprValue* AstExpression::eval_internal()
{
/*
* Already evaluated?
*/
if ( m_exprValue != NULL )
- return eval_kind(m_exprValue, ek);
+ return m_exprValue;
/*
* OK, must evaluate operator
*/
@@ -908,23 +889,23 @@ AstExprValue* AstExpression::eval_internal(EvalKind ek)
case EC_mul:
case EC_div:
case EC_mod:
- m_exprValue = eval_bin_op(ek);
- return eval_kind(m_exprValue, ek);
+ m_exprValue = eval_bin_op();
+ return m_exprValue;
case EC_or:
case EC_xor:
case EC_and:
case EC_left:
case EC_right:
- m_exprValue = eval_bit_op(ek);
- return eval_kind(m_exprValue, ek);
+ m_exprValue = eval_bit_op();
+ return m_exprValue;
case EC_u_plus:
case EC_u_minus:
case EC_bit_neg:
- m_exprValue = eval_un_op(ek);
- return eval_kind(m_exprValue, ek);
+ m_exprValue = eval_un_op();
+ return m_exprValue;
case EC_symbol:
- m_exprValue = eval_symbol(ek);
- return eval_kind(m_exprValue, ek);
+ m_exprValue = eval_symbol();
+ return m_exprValue;
case EC_none:
return NULL;
}
@@ -932,24 +913,22 @@ AstExprValue* AstExpression::eval_internal(EvalKind ek)
return NULL;
}
-AstExprValue* AstExpression::eval_bin_op(EvalKind ek)
+AstExprValue* AstExpression::eval_bin_op()
{
ExprType eType = ET_double;
if ( m_combOperator == EC_mod )
eType = ET_hyper;
- if (ek != EK_const && ek != EK_positive_int)
- return NULL;
if (m_subExpr1 == NULL || m_subExpr2 == NULL)
return NULL;
- m_subExpr1->setExprValue(m_subExpr1->eval_internal(ek));
+ m_subExpr1->setExprValue(m_subExpr1->eval_internal());
if (m_subExpr1->getExprValue() == NULL)
return NULL;
m_subExpr1->setExprValue(m_subExpr1->coerce(eType));
if (m_subExpr1->getExprValue() == NULL)
return NULL;
- m_subExpr2->setExprValue(m_subExpr2->eval_internal(ek));
+ m_subExpr2->setExprValue(m_subExpr2->eval_internal());
if (m_subExpr2->getExprValue() == NULL)
return NULL;
m_subExpr2->setExprValue(m_subExpr2->coerce(eType));
@@ -987,19 +966,17 @@ AstExprValue* AstExpression::eval_bin_op(EvalKind ek)
return retval.release();
}
-AstExprValue* AstExpression::eval_bit_op(EvalKind ek)
+AstExprValue* AstExpression::eval_bit_op()
{
- if (ek != EK_const && ek != EK_positive_int)
- return NULL;
if (m_subExpr1 == NULL || m_subExpr2 == NULL)
return NULL;
- m_subExpr1->setExprValue(m_subExpr1->eval_internal(ek));
+ m_subExpr1->setExprValue(m_subExpr1->eval_internal());
if (m_subExpr1->getExprValue() == NULL)
return NULL;
m_subExpr1->setExprValue(m_subExpr1->coerce(ET_long));
if (m_subExpr1->getExprValue() == NULL)
return NULL;
- m_subExpr2->setExprValue(m_subExpr2->eval_internal(ek));
+ m_subExpr2->setExprValue(m_subExpr2->eval_internal());
if (m_subExpr2->getExprValue() == NULL)
return NULL;
m_subExpr2->setExprValue(m_subExpr2->coerce(ET_long));
@@ -1033,16 +1010,14 @@ AstExprValue* AstExpression::eval_bit_op(EvalKind ek)
return retval.release();
}
-AstExprValue* AstExpression::eval_un_op(EvalKind ek)
+AstExprValue* AstExpression::eval_un_op()
{
if (m_exprValue != NULL)
return m_exprValue;
- if (ek != EK_const && ek != EK_positive_int)
- return NULL;
if (m_subExpr1 == NULL)
return NULL;
- m_subExpr1->setExprValue(m_subExpr1->eval_internal(ek));
+ m_subExpr1->setExprValue(m_subExpr1->eval_internal());
if (m_subExpr1->getExprValue() == NULL)
return NULL;
m_subExpr1->setExprValue(m_subExpr1->coerce(ET_double));
@@ -1073,7 +1048,7 @@ AstExprValue* AstExpression::eval_un_op(EvalKind ek)
return retval.release();
}
-AstExprValue* AstExpression::eval_symbol(EvalKind ek)
+AstExprValue* AstExpression::eval_symbol()
{
AstScope *pScope = 0;
AstDeclaration *pDecl;
@@ -1123,7 +1098,7 @@ AstExprValue* AstExpression::eval_symbol(EvalKind ek)
* OK, now evaluate the constant we just got, to produce its value
*/
pConst = static_cast< AstConstant* >(pDecl);
- return pConst->getConstValue()->eval_internal(ek);
+ return pConst->getConstValue()->eval_internal();
}
OString AstExpression::toString()
diff --git a/idlc/source/parser.y b/idlc/source/parser.y
index 52bcdf862b7f..c449aa7e6bcc 100644
--- a/idlc/source/parser.y
+++ b/idlc/source/parser.y
@@ -2719,7 +2719,7 @@ enumerator :
if ( $3 && pScope && pScope->getScopeNodeType() == NT_enum)
{
- $3->evaluate(EK_const);
+ $3->evaluate();
if ( $3->coerce(ET_long) )
{
pEnum = static_cast<AstEnum*>(pScope);