diff options
Diffstat (limited to 'idlc/source/astexpression.cxx')
-rw-r--r-- | idlc/source/astexpression.cxx | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/idlc/source/astexpression.cxx b/idlc/source/astexpression.cxx index a93c13ecf8ba..357da1ab362e 100644 --- a/idlc/source/astexpression.cxx +++ b/idlc/source/astexpression.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_idlc.hxx" + #include <idlc/astexpression.hxx> #include <idlc/astconstant.hxx> #include <idlc/astscope.hxx> @@ -34,6 +35,7 @@ #include <limits.h> #include <float.h> +#include <memory> // auto_ptr<> #undef MAXCHAR #define MAXCHAR 127 @@ -927,7 +929,6 @@ AstExprValue* AstExpression::eval_internal(EvalKind ek) AstExprValue* AstExpression::eval_bin_op(EvalKind ek) { - AstExprValue *retval = NULL; ExprType eType = ET_double; if ( m_combOperator == EC_mod ) @@ -950,7 +951,7 @@ AstExprValue* AstExpression::eval_bin_op(EvalKind ek) if (m_subExpr2->getExprValue() == NULL) return NULL; - retval = new AstExprValue(); + std::auto_ptr< AstExprValue > retval(new AstExprValue()); retval->et = eType; switch (m_combOperator) @@ -971,20 +972,18 @@ AstExprValue* AstExpression::eval_bin_op(EvalKind ek) break; case EC_div: if (m_subExpr2->getExprValue()->u.dval == 0.0) - return NULL; + return NULL; retval->u.dval = m_subExpr1->getExprValue()->u.dval / m_subExpr2->getExprValue()->u.dval; break; default: return NULL; } - return retval; + return retval.release(); } AstExprValue* AstExpression::eval_bit_op(EvalKind ek) { - AstExprValue *retval = NULL; - if (ek != EK_const && ek != EK_positive_int) return NULL; if (m_subExpr1 == NULL || m_subExpr2 == NULL) @@ -1002,7 +1001,7 @@ AstExprValue* AstExpression::eval_bit_op(EvalKind ek) if (m_subExpr2->getExprValue() == NULL) return NULL; - retval = new AstExprValue; + std::auto_ptr< AstExprValue > retval(new AstExprValue()); retval->et = ET_long; switch (m_combOperator) @@ -1026,13 +1025,11 @@ AstExprValue* AstExpression::eval_bit_op(EvalKind ek) return NULL; } - return retval; + return retval.release(); } AstExprValue* AstExpression::eval_un_op(EvalKind ek) { - AstExprValue *retval = NULL; - if (m_exprValue != NULL) return m_exprValue; @@ -1047,7 +1044,7 @@ AstExprValue* AstExpression::eval_un_op(EvalKind ek) if (m_subExpr1->getExprValue() == NULL) return NULL; - retval = new AstExprValue(); + std::auto_ptr< AstExprValue > retval(new AstExprValue()); retval->et = ET_double; switch (m_combOperator) @@ -1068,7 +1065,7 @@ AstExprValue* AstExpression::eval_un_op(EvalKind ek) return NULL; } - return retval; + return retval.release(); } AstExprValue* AstExpression::eval_symbol(EvalKind ek) |