idlc/inc/idlc/astexpression.hxx | 16 - idlc/source/astexpression.cxx | 406 ++++++++++++++---------------- solenv/bin/macosx-change-install-names.pl | 2 3 files changed, 205 insertions(+), 219 deletions(-)
New commits: commit 262b5e0b3e870ea51c590de8d6cc34111c34ad0f Author: Stephan Bergmann <sberg...@redhat.com> Date: Sun Sep 27 19:27:35 2015 +0200 SDK apps actually find URE libs via DYLD_LIBRARY_PATH Change-Id: I29c8177ee0c79f7e2b1834d4c181289cccfab17a diff --git a/solenv/bin/macosx-change-install-names.pl b/solenv/bin/macosx-change-install-names.pl index 0322872..ee8320c 100644 --- a/solenv/bin/macosx-change-install-names.pl +++ b/solenv/bin/macosx-change-install-names.pl @@ -49,7 +49,7 @@ sub action($$$) ('app/UREBIN/URELIB' => '@executable_path/../Frameworks', 'app/OOO/URELIB' => '@executable_path/../Frameworks', 'app/OOO/OOO' => '@executable_path/../Frameworks', - 'app/SDKBIN/URELIB' => '@executable_path/../Frameworks', + 'app/SDKBIN/URELIB' => '@__VIA_LIBRARY_PATH__', 'app/NONE/URELIB' => '@__VIA_LIBRARY_PATH__', 'app/NONE/OOO' => '@__VIA_LIBRARY_PATH__', 'app/NONE/NONE' => '@__VIA_LIBRARY_PATH__', commit a5bb6eff8672f5a6e7ed1f885f69ca8434db6ce7 Author: Stephan Bergmann <sberg...@redhat.com> Date: Sun Sep 27 19:23:05 2015 +0200 Return unique_ptr from AstExpression::eval_* functions ...generally, idlc leaks most memory, and e.g. trying to turn AstExpression::m_exprValue into a unique_ptr would fail because AstExpression::eval_symbol returns a pointer to an object "owned" elsewhere (but never actually deleted by its owner). So improvement of idlc ends here---for one, it does not improve anything to try and make idlc not leak memory, and for another, idlc is doomed to go away anyway. Change-Id: I36f54130c8bfd1933126ae7f8a982e50d9bc616e diff --git a/idlc/inc/idlc/astexpression.hxx b/idlc/inc/idlc/astexpression.hxx index deb0da4..6723297 100644 --- a/idlc/inc/idlc/astexpression.hxx +++ b/idlc/inc/idlc/astexpression.hxx @@ -19,6 +19,10 @@ #ifndef INCLUDED_IDLC_INC_IDLC_ASTEXPRESSION_HXX #define INCLUDED_IDLC_INC_IDLC_ASTEXPRESSION_HXX +#include <sal/config.h> + +#include <memory> + #include <idlc/idlc.hxx> // Enum to define all the different operators to combine expressions @@ -120,9 +124,9 @@ private: // Fill out the lineno, filename and definition scope details void fillDefinitionDetails(); // Evaluate different sets of operators - AstExprValue* eval_bin_op(); - AstExprValue* eval_bit_op(); - AstExprValue* eval_un_op(); + std::unique_ptr<AstExprValue> eval_bin_op(); + std::unique_ptr<AstExprValue> eval_bit_op(); + std::unique_ptr<AstExprValue> eval_un_op(); AstExprValue* eval_symbol(); AstScope* m_pScope; // scope defined in diff --git a/idlc/source/astexpression.cxx b/idlc/source/astexpression.cxx index 3798b7a..593cdb6 100644 --- a/idlc/source/astexpression.cxx +++ b/idlc/source/astexpression.cxx @@ -885,19 +885,19 @@ void AstExpression::evaluate() case EC_mul: case EC_div: case EC_mod: - m_exprValue = eval_bin_op(); + m_exprValue = eval_bin_op().release(); break; case EC_or: case EC_xor: case EC_and: case EC_left: case EC_right: - m_exprValue = eval_bit_op(); + m_exprValue = eval_bit_op().release(); break; case EC_u_plus: case EC_u_minus: case EC_bit_neg: - m_exprValue = eval_un_op(); + m_exprValue = eval_un_op().release(); break; case EC_symbol: m_exprValue = eval_symbol(); @@ -907,7 +907,7 @@ void AstExpression::evaluate() } } -AstExprValue* AstExpression::eval_bin_op() +std::unique_ptr<AstExprValue> AstExpression::eval_bin_op() { ExprType eType = ET_double; @@ -955,10 +955,10 @@ AstExprValue* AstExpression::eval_bin_op() return NULL; } - return retval.release(); + return retval; } -AstExprValue* AstExpression::eval_bit_op() +std::unique_ptr<AstExprValue> AstExpression::eval_bit_op() { if (m_subExpr1 == NULL || m_subExpr2 == NULL) return NULL; @@ -997,10 +997,10 @@ AstExprValue* AstExpression::eval_bit_op() return NULL; } - return retval.release(); + return retval; } -AstExprValue* AstExpression::eval_un_op() +std::unique_ptr<AstExprValue> AstExpression::eval_un_op() { if (m_subExpr1 == NULL) return NULL; @@ -1030,7 +1030,7 @@ AstExprValue* AstExpression::eval_un_op() return NULL; } - return retval.release(); + return retval; } AstExprValue* AstExpression::eval_symbol() commit 1f8723bf91bd48d432f1d2b930d0908ff28f44df Author: Stephan Bergmann <sberg...@redhat.com> Date: Sat Sep 26 22:55:04 2015 +0200 m_exprValue cannot be non-null here ...as, like the other private AstExpression::eval_* functions, eval_un_op is only called from AstExpression::evaluate if m_exprValue is null Change-Id: I812ea249d33a72f95b9692dc72ba6631ffbd4884 diff --git a/idlc/source/astexpression.cxx b/idlc/source/astexpression.cxx index 3927a3f..3798b7a 100644 --- a/idlc/source/astexpression.cxx +++ b/idlc/source/astexpression.cxx @@ -1002,9 +1002,6 @@ AstExprValue* AstExpression::eval_bit_op() AstExprValue* AstExpression::eval_un_op() { - if (m_exprValue != NULL) - return m_exprValue; - if (m_subExpr1 == NULL) return NULL; m_subExpr1->evaluate(); commit 84001596c9ee3d616ba9f0afffb5b1e959278f6c Author: Stephan Bergmann <sberg...@redhat.com> Date: Sat Sep 26 22:37:12 2015 +0200 AstExpression::coerce always returned m_exprValue, so simplify its signature Change-Id: I4fa380bc7e8d5b3581468cb0e6417b99587a1e9f diff --git a/idlc/inc/idlc/astexpression.hxx b/idlc/inc/idlc/astexpression.hxx index 1bd6f96..deb0da4 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 c796ed5..3927a3f 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; commit b085d55e5546c94d4e6e0f8cb6ff6d9f28c9d2e6 Author: Stephan Bergmann <sberg...@redhat.com> Date: Sat Sep 26 22:30:59 2015 +0200 Remove redundant AstExpression::eval_internal Change-Id: I27c067adb2b09ad65a8449f2d88a9cdde149d4be diff --git a/idlc/inc/idlc/astexpression.hxx b/idlc/inc/idlc/astexpression.hxx index 32364fa..1bd6f96 100644 --- a/idlc/inc/idlc/astexpression.hxx +++ b/idlc/inc/idlc/astexpression.hxx @@ -121,8 +121,6 @@ public: private: // Fill out the lineno, filename and definition scope details void fillDefinitionDetails(); - // Internal evaluation - void eval_internal(); // Evaluate different sets of operators AstExprValue* eval_bin_op(); AstExprValue* eval_bit_op(); diff --git a/idlc/source/astexpression.cxx b/idlc/source/astexpression.cxx index 9e0469a..c796ed5 100644 --- a/idlc/source/astexpression.cxx +++ b/idlc/source/astexpression.cxx @@ -700,7 +700,7 @@ AstExprValue* AstExpression::coerce(ExprType t) * First, evaluate it, then try to coerce result type * If already evaluated, return the result */ - eval_internal(); + evaluate(); if (m_exprValue == NULL) return NULL; @@ -758,11 +758,6 @@ AstExprValue* AstExpression::coerce(ExprType t) return copy; } -void AstExpression::evaluate() -{ - eval_internal(); -} - bool AstExpression::operator==(AstExpression *pExpr) { bool bRet = false; @@ -873,7 +868,7 @@ void AstExpression::fillDefinitionDetails() m_fileName = idlc()->getFileName(); } -void AstExpression::eval_internal() +void AstExpression::evaluate() { /* * Already evaluated? @@ -921,13 +916,13 @@ AstExprValue* AstExpression::eval_bin_op() if (m_subExpr1 == NULL || m_subExpr2 == NULL) return NULL; - m_subExpr1->eval_internal(); + m_subExpr1->evaluate(); if (m_subExpr1->getExprValue() == NULL) return NULL; m_subExpr1->setExprValue(m_subExpr1->coerce(eType)); if (m_subExpr1->getExprValue() == NULL) return NULL; - m_subExpr2->eval_internal(); + m_subExpr2->evaluate(); if (m_subExpr2->getExprValue() == NULL) return NULL; m_subExpr2->setExprValue(m_subExpr2->coerce(eType)); @@ -969,13 +964,13 @@ AstExprValue* AstExpression::eval_bit_op() { if (m_subExpr1 == NULL || m_subExpr2 == NULL) return NULL; - m_subExpr1->eval_internal(); + m_subExpr1->evaluate(); if (m_subExpr1->getExprValue() == NULL) return NULL; m_subExpr1->setExprValue(m_subExpr1->coerce(ET_long)); if (m_subExpr1->getExprValue() == NULL) return NULL; - m_subExpr2->eval_internal(); + m_subExpr2->evaluate(); if (m_subExpr2->getExprValue() == NULL) return NULL; m_subExpr2->setExprValue(m_subExpr2->coerce(ET_long)); @@ -1016,7 +1011,7 @@ AstExprValue* AstExpression::eval_un_op() if (m_subExpr1 == NULL) return NULL; - m_subExpr1->eval_internal(); + m_subExpr1->evaluate(); if (m_subExpr1->getExprValue() == NULL) return NULL; m_subExpr1->setExprValue(m_subExpr1->coerce(ET_double)); @@ -1097,7 +1092,7 @@ AstExprValue* AstExpression::eval_symbol() * OK, now evaluate the constant we just got, to produce its value */ pConst = static_cast< AstConstant* >(pDecl); - pConst->getConstValue()->eval_internal(); + pConst->getConstValue()->evaluate(); return pConst->getConstValue()->getExprValue(); } commit cb31ea6981a336c16bc29ef2f0d323da9fb2dda4 Author: Stephan Bergmann <sberg...@redhat.com> Date: Sat Sep 26 22:29:24 2015 +0200 AstExpression::eval_internal always returns m_exprValue Change-Id: I214fb3d14cef07357860a88fae1652a7d1a282b0 diff --git a/idlc/inc/idlc/astexpression.hxx b/idlc/inc/idlc/astexpression.hxx index 32c8bc7..32364fa 100644 --- a/idlc/inc/idlc/astexpression.hxx +++ b/idlc/inc/idlc/astexpression.hxx @@ -122,7 +122,7 @@ private: // Fill out the lineno, filename and definition scope details void fillDefinitionDetails(); // Internal evaluation - AstExprValue* eval_internal(); + void eval_internal(); // Evaluate different sets of operators AstExprValue* eval_bin_op(); AstExprValue* eval_bit_op(); diff --git a/idlc/source/astexpression.cxx b/idlc/source/astexpression.cxx index 0fec297..9e0469a 100644 --- a/idlc/source/astexpression.cxx +++ b/idlc/source/astexpression.cxx @@ -700,7 +700,7 @@ AstExprValue* AstExpression::coerce(ExprType t) * First, evaluate it, then try to coerce result type * If already evaluated, return the result */ - m_exprValue = eval_internal(); + eval_internal(); if (m_exprValue == NULL) return NULL; @@ -760,7 +760,7 @@ AstExprValue* AstExpression::coerce(ExprType t) void AstExpression::evaluate() { - m_exprValue = eval_internal(); + eval_internal(); } bool AstExpression::operator==(AstExpression *pExpr) @@ -873,13 +873,13 @@ void AstExpression::fillDefinitionDetails() m_fileName = idlc()->getFileName(); } -AstExprValue* AstExpression::eval_internal() +void AstExpression::eval_internal() { /* * Already evaluated? */ if ( m_exprValue != NULL ) - return m_exprValue; + return; /* * OK, must evaluate operator */ @@ -891,27 +891,25 @@ AstExprValue* AstExpression::eval_internal() case EC_div: case EC_mod: m_exprValue = eval_bin_op(); - return m_exprValue; + break; case EC_or: case EC_xor: case EC_and: case EC_left: case EC_right: m_exprValue = eval_bit_op(); - return m_exprValue; + break; case EC_u_plus: case EC_u_minus: case EC_bit_neg: m_exprValue = eval_un_op(); - return m_exprValue; + break; case EC_symbol: m_exprValue = eval_symbol(); - return m_exprValue; + break; case EC_none: - return NULL; + break; } - - return NULL; } AstExprValue* AstExpression::eval_bin_op() @@ -923,13 +921,13 @@ AstExprValue* AstExpression::eval_bin_op() if (m_subExpr1 == NULL || m_subExpr2 == NULL) return NULL; - m_subExpr1->setExprValue(m_subExpr1->eval_internal()); + 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()); + m_subExpr2->eval_internal(); if (m_subExpr2->getExprValue() == NULL) return NULL; m_subExpr2->setExprValue(m_subExpr2->coerce(eType)); @@ -971,13 +969,13 @@ AstExprValue* AstExpression::eval_bit_op() { if (m_subExpr1 == NULL || m_subExpr2 == NULL) return NULL; - m_subExpr1->setExprValue(m_subExpr1->eval_internal()); + 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()); + m_subExpr2->eval_internal(); if (m_subExpr2->getExprValue() == NULL) return NULL; m_subExpr2->setExprValue(m_subExpr2->coerce(ET_long)); @@ -1018,7 +1016,7 @@ AstExprValue* AstExpression::eval_un_op() if (m_subExpr1 == NULL) return NULL; - m_subExpr1->setExprValue(m_subExpr1->eval_internal()); + m_subExpr1->eval_internal(); if (m_subExpr1->getExprValue() == NULL) return NULL; m_subExpr1->setExprValue(m_subExpr1->coerce(ET_double)); @@ -1099,7 +1097,8 @@ AstExprValue* AstExpression::eval_symbol() * OK, now evaluate the constant we just got, to produce its value */ pConst = static_cast< AstConstant* >(pDecl); - return pConst->getConstValue()->eval_internal(); + pConst->getConstValue()->eval_internal(); + return pConst->getConstValue()->getExprValue(); } OString AstExpression::toString() commit 6b3feb91b8c0d78e49c0b0bcb969879c980505be Author: Stephan Bergmann <sberg...@redhat.com> Date: Sat Sep 26 22:22:08 2015 +0200 AstExpression::coerce is always called with bAssign = true Change-Id: I883b8319fde0bd3cc65efe64eb2faf53e2344cfc diff --git a/idlc/inc/idlc/astexpression.hxx b/idlc/inc/idlc/astexpression.hxx index 327cbe9..32c8bc7 100644 --- a/idlc/inc/idlc/astexpression.hxx +++ b/idlc/inc/idlc/astexpression.hxx @@ -108,7 +108,7 @@ public: { m_exprValue = pEv; } // Evaluation and value coercion - AstExprValue* coerce(ExprType type, bool bAssign=true); + AstExprValue* 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 785e228..0fec297 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 bAssign) +AstExprValue* AstExpression::coerce(ExprType t) { AstExprValue *copy; @@ -753,8 +753,7 @@ AstExprValue* AstExpression::coerce(ExprType t, bool bAssign) copy = nullptr; } - if (bAssign) - m_exprValue = copy; + m_exprValue = copy; return copy; } commit 2b19fd857043c6c6b5150b71ab42361494172d5e Author: Stephan Bergmann <sberg...@redhat.com> Date: Sat Sep 26 22:19:57 2015 +0200 Simplify coerce_value signature Change-Id: I0791600a5cc8600ea80233afba07724dd7f565e1 diff --git a/idlc/source/astexpression.cxx b/idlc/source/astexpression.cxx index 3bde391..785e228 100644 --- a/idlc/source/astexpression.cxx +++ b/idlc/source/astexpression.cxx @@ -133,11 +133,11 @@ AstExpression::~AstExpression() * ExprType. Return an AstExprValue if successful, NULL if failed. * must be done for hyper, uhyper */ -static AstExprValue * +static bool coerce_value(AstExprValue *ev, ExprType t) { if (ev == NULL) - return NULL; + return false; switch (t) { @@ -145,119 +145,119 @@ coerce_value(AstExprValue *ev, ExprType t) switch (ev->et) { case ET_short: - return ev; + return true; case ET_ushort: if (ev->u.usval > SAL_MAX_INT16) - return NULL; + return false; ev->u.sval = (sal_Int16)ev->u.usval; ev->et = ET_short; - return ev; + return true; case ET_long: if (ev->u.lval < SAL_MIN_INT16 || ev->u.lval > SAL_MAX_INT16) - return NULL; + return false; ev->u.sval = (sal_Int16)ev->u.lval; ev->et = ET_short; - return ev; + return true; case ET_ulong: if (ev->u.ulval > SAL_MAX_INT16) - return NULL; + return false; ev->u.sval = (sal_Int16)ev->u.ulval; ev->et = ET_short; - return ev; + return true; case ET_hyper: if (ev->u.hval < SAL_MIN_INT16 || ev->u.hval > SAL_MAX_INT16) - return NULL; + return false; ev->u.sval = (sal_Int16)ev->u.hval; ev->et = ET_short; - return ev; + return true; case ET_uhyper: if (ev->u.uhval > SAL_MAX_INT16) - return NULL; + return false; ev->u.sval = (sal_Int16)ev->u.uhval; ev->et = ET_short; - return ev; + return true; case ET_boolean: ev->u.sval = (sal_Int16)ev->u.bval; ev->et = ET_short; - return ev; + return true; case ET_float: if (ev->u.fval < SAL_MIN_INT16 || ev->u.fval > SAL_MAX_INT16) - return NULL; + return false; ev->u.sval = (sal_Int16)ev->u.fval; ev->et = ET_short; - return ev; + return true; case ET_double: if (ev->u.dval < SAL_MIN_INT16 || ev->u.dval > SAL_MAX_INT16) - return NULL; + return false; ev->u.sval = (sal_Int16)ev->u.dval; ev->et = ET_short; - return ev; + return true; case ET_byte: ev->u.sval = (sal_Int16)ev->u.byval; ev->et = ET_short; - return ev; + return true; default: OSL_ASSERT(false); - return NULL; + return false; } case ET_ushort: switch (ev->et) { case ET_short: if (ev->u.sval < 0) - return NULL; + return false; ev->u.usval = (sal_uInt16)ev->u.sval; ev->et = ET_ushort; - return ev; + return true; case ET_ushort: - return ev; + return true; case ET_long: if (ev->u.lval < 0 || ev->u.lval > SAL_MAX_UINT16) - return NULL; + return false; ev->u.usval = (sal_uInt16)ev->u.lval; ev->et = ET_ushort; - return ev; + return true; case ET_ulong: if (ev->u.ulval > SAL_MAX_UINT16) - return NULL; + return false; ev->u.usval = (sal_uInt16)ev->u.ulval; ev->et = ET_ushort; - return ev; + return true; case ET_hyper: if (ev->u.hval < 0 || ev->u.hval > SAL_MAX_UINT16) - return NULL; + return false; ev->u.usval = (sal_uInt16)ev->u.hval; ev->et = ET_ushort; - return ev; + return true; case ET_uhyper: if (ev->u.uhval > SAL_MAX_UINT16) - return NULL; + return false; ev->u.usval = (sal_uInt16)ev->u.uhval; ev->et = ET_ushort; - return ev; + return true; case ET_boolean: ev->u.usval = (sal_uInt16)ev->u.bval; ev->et = ET_short; - return ev; + return true; case ET_float: if (ev->u.fval < 0.0 || ev->u.fval > SAL_MAX_UINT16) - return NULL; + return false; ev->u.usval = (sal_uInt16)ev->u.fval; ev->et = ET_short; - return ev; + return true; case ET_double: if (ev->u.dval < 0.0 || ev->u.dval > SAL_MAX_UINT16) - return NULL; + return false; ev->u.usval = (sal_uInt16)ev->u.dval; ev->et = ET_short; - return ev; + return true; case ET_byte: ev->u.usval = (sal_uInt16)ev->u.byval; ev->et = ET_ushort; - return ev; + return true; default: OSL_ASSERT(false); - return NULL; + return false; } case ET_long: switch (ev->et) @@ -265,111 +265,111 @@ coerce_value(AstExprValue *ev, ExprType t) case ET_short: ev->u.lval = (sal_Int32)ev->u.sval; ev->et = ET_long; - return ev; + return true; case ET_ushort: ev->u.lval = (sal_Int32)ev->u.usval; ev->et = ET_long; - return ev; + return true; case ET_long: - return ev; + return true; case ET_ulong: if (ev->u.ulval > SAL_MAX_INT32) - return NULL; + return false; ev->u.lval = (sal_Int32)ev->u.ulval; ev->et = ET_long; - return ev; + return true; case ET_hyper: if (ev->u.hval < SAL_MIN_INT32 || ev->u.hval > SAL_MAX_INT32) - return NULL; + return false; ev->u.lval = (sal_Int32)ev->u.hval; ev->et = ET_long; - return ev; + return true; case ET_uhyper: if (ev->u.uhval > SAL_MAX_INT32) - return NULL; + return false; ev->u.lval = (sal_Int32)ev->u.uhval; ev->et = ET_long; - return ev; + return true; case ET_boolean: ev->u.lval = (sal_Int32)ev->u.bval; ev->et = ET_long; - return ev; + return true; case ET_float: if (ev->u.fval < SAL_MIN_INT32 || ev->u.fval > SAL_MAX_INT32) - return NULL; + return false; ev->u.lval = (sal_Int32)ev->u.fval; ev->et = ET_long; - return ev; + return true; case ET_double: if (ev->u.dval < SAL_MIN_INT32 || ev->u.dval > SAL_MAX_INT32) - return NULL; + return false; ev->u.lval = (sal_Int32)ev->u.dval; ev->et = ET_long; - return ev; + return true; case ET_byte: ev->u.lval = (sal_Int32) ev->u.byval; ev->et = ET_long; - return ev; + return true; default: OSL_ASSERT(false); - return NULL; + return false; } case ET_ulong: switch (ev->et) { case ET_short: if (ev->u.sval < 0) - return NULL; + return false; ev->u.ulval = (sal_uInt32)ev->u.sval; ev->et = ET_ulong; - return ev; + return true; case ET_ushort: ev->u.ulval = (sal_uInt32)ev->u.usval; ev->et = ET_ulong; - return ev; + return true; case ET_long: if (ev->u.lval < 0) - return NULL; + return false; ev->u.ulval = (sal_uInt32)ev->u.lval; ev->et = ET_ulong; - return ev; + return true; case ET_ulong: - return ev; + return true; case ET_hyper: if (ev->u.hval < 0 || ev->u.hval > SAL_MAX_UINT32) - return NULL; + return false; ev->u.lval = (sal_uInt32)ev->u.hval; ev->et = ET_ulong; - return ev; + return true; case ET_uhyper: if (ev->u.uhval > SAL_MAX_UINT32) - return NULL; + return false; ev->u.ulval = (sal_uInt32)ev->u.uhval; ev->et = ET_ulong; - return ev; + return true; case ET_boolean: ev->u.ulval = (sal_uInt32)ev->u.bval; ev->et = ET_ulong; - return ev; + return true; case ET_float: if (ev->u.fval < 0.0 || ev->u.fval > SAL_MAX_UINT32) - return NULL; + return false; ev->u.ulval = (sal_uInt32)ev->u.fval; ev->et = ET_ulong; - return ev; + return true; case ET_double: if (ev->u.dval < 0.0 || ev->u.dval > SAL_MAX_UINT32) - return NULL; + return false; ev->u.ulval = (sal_uInt32)ev->u.dval; ev->et = ET_ulong; - return ev; + return true; case ET_byte: ev->u.ulval = (sal_uInt32)ev->u.byval; ev->et = ET_ulong; - return ev; + return true; default: OSL_ASSERT(false); - return NULL; + return false; } case ET_hyper: switch (ev->et) @@ -377,105 +377,105 @@ coerce_value(AstExprValue *ev, ExprType t) case ET_short: ev->u.hval = (sal_Int64)ev->u.sval; ev->et = ET_hyper; - return ev; + return true; case ET_ushort: ev->u.hval = (sal_Int64)ev->u.usval; ev->et = ET_hyper; - return ev; + return true; case ET_long: ev->u.hval = (sal_Int64)ev->u.lval; ev->et = ET_hyper; - return ev; + return true; case ET_ulong: ev->u.hval = (sal_Int64)ev->u.ulval; ev->et = ET_hyper; - return ev; + return true; case ET_hyper: - return ev; + return true; case ET_uhyper: if (ev->u.uhval > SAL_MAX_INT64) - return NULL; + return false; ev->u.hval = (sal_Int64)ev->u.uhval; ev->et = ET_long; - return ev; + return true; case ET_boolean: ev->u.hval = (sal_Int64)ev->u.bval; ev->et = ET_hyper; - return ev; + return true; case ET_float: if (ev->u.fval < SAL_MIN_INT64 || ev->u.fval > SAL_MAX_INT64) - return NULL; + return false; ev->u.hval = (sal_Int64)ev->u.fval; ev->et = ET_hyper; - return ev; + return true; case ET_double: if (ev->u.dval < SAL_MIN_INT64 || ev->u.dval > SAL_MAX_INT64) - return NULL; + return false; ev->u.hval = (sal_Int64)ev->u.dval; ev->et = ET_hyper; - return ev; + return true; case ET_byte: ev->u.hval = (sal_Int64)ev->u.byval; ev->et = ET_hyper; - return ev; + return true; default: OSL_ASSERT(false); - return NULL; + return false; } case ET_uhyper: switch (ev->et) { case ET_short: if (ev->u.sval < 0) - return NULL; + return false; ev->u.uhval = (sal_uInt64)ev->u.sval; ev->et = ET_uhyper; - return ev; + return true; case ET_ushort: ev->u.uhval = (sal_uInt64)ev->u.usval; ev->et = ET_uhyper; - return ev; + return true; case ET_long: if (ev->u.lval < 0) - return NULL; + return false; ev->u.uhval = (sal_uInt64)ev->u.lval; ev->et = ET_uhyper; - return ev; + return true; case ET_ulong: ev->u.uhval = (sal_uInt64)ev->u.ulval; ev->et = ET_uhyper; - return ev; + return true; case ET_hyper: if (ev->u.hval < 0) - return NULL; + return false; ev->u.uhval = (sal_uInt64)ev->u.hval; ev->et = ET_uhyper; - return ev; + return true; case ET_uhyper: - return ev; + return true; case ET_boolean: ev->u.uhval = (sal_uInt64)ev->u.bval; ev->et = ET_uhyper; - return ev; + return true; case ET_float: if (ev->u.fval < 0.0 || ev->u.fval > SAL_MAX_UINT64) - return NULL; + return false; ev->u.uhval = (sal_uInt64)ev->u.fval; ev->et = ET_uhyper; - return ev; + return true; case ET_double: if (ev->u.dval < 0.0 || ev->u.dval > SAL_MAX_UINT64) - return NULL; + return false; ev->u.uhval = (sal_uInt64)ev->u.dval; ev->et = ET_uhyper; - return ev; + return true; case ET_byte: ev->u.uhval = (sal_uInt64)ev->u.byval; ev->et = ET_uhyper; - return ev; + return true; default: OSL_ASSERT(false); - return NULL; + return false; } case ET_boolean: switch (ev->et) @@ -483,44 +483,44 @@ coerce_value(AstExprValue *ev, ExprType t) case ET_short: ev->u.bval = ev->u.sval != 0; ev->et = ET_boolean; - return ev; + return true; case ET_ushort: ev->u.bval = ev->u.usval != 0; ev->et = ET_boolean; - return ev; + return true; case ET_long: ev->u.bval = ev->u.lval != 0; ev->et = ET_boolean; - return ev; + return true; case ET_ulong: ev->u.bval = ev->u.ulval != 0; ev->et = ET_boolean; - return ev; + return true; case ET_hyper: ev->u.bval = ev->u.hval != 0; ev->et = ET_boolean; - return ev; + return true; case ET_uhyper: ev->u.bval = ev->u.uhval != 0; ev->et = ET_boolean; - return ev; + return true; case ET_boolean: - return ev; + return true; case ET_float: ev->u.bval = ev->u.fval != 0.0; ev->et = ET_boolean; - return ev; + return true; case ET_double: ev->u.bval = ev->u.dval != 0.0; ev->et = ET_boolean; - return ev; + return true; case ET_byte: ev->u.bval = ev->u.byval != 0; ev->et = ET_boolean; - return ev; + return true; default: OSL_ASSERT(false); - return NULL; + return false; } case ET_float: switch (ev->et) @@ -528,48 +528,48 @@ coerce_value(AstExprValue *ev, ExprType t) case ET_short: ev->u.fval = (float)ev->u.sval; ev->et = ET_float; - return ev; + return true; case ET_ushort: ev->u.fval = (float)ev->u.usval; ev->et = ET_float; - return ev; + return true; case ET_long: ev->u.fval = (float)ev->u.lval; ev->et = ET_float; - return ev; + return true; case ET_ulong: ev->u.fval = (float)ev->u.ulval; ev->et = ET_float; - return ev; + return true; case ET_hyper: ev->u.fval = (float)ev->u.hval; ev->et = ET_float; - return ev; + return true; case ET_uhyper: if ((float)ev->u.ulval > FLT_MAX) - return NULL; + return false; ev->u.fval = (float)ev->u.ulval; ev->et = ET_float; - return ev; + return true; case ET_boolean: ev->u.fval = ev->u.bval ? 1.0f : 0.0f; ev->et = ET_float; - return ev; + return true; case ET_float: - return ev; + return true; case ET_double: if ((float)ev->u.dval > FLT_MAX || (float)ev->u.dval < -FLT_MAX) - return NULL; + return false; ev->u.fval = (float)ev->u.dval; ev->et = ET_float; - return ev; + return true; case ET_byte: ev->u.fval = (float)ev->u.byval; ev->et = ET_float; - return ev; + return true; default: OSL_ASSERT(false); - return NULL; + return false; } case ET_double: switch (ev->et) @@ -577,111 +577,111 @@ coerce_value(AstExprValue *ev, ExprType t) case ET_short: ev->u.dval = (double)ev->u.sval; ev->et = ET_double; - return ev; + return true; case ET_ushort: ev->u.dval = (double)ev->u.usval; ev->et = ET_double; - return ev; + return true; case ET_long: ev->u.dval = (double)ev->u.lval; ev->et = ET_double; - return ev; + return true; case ET_ulong: ev->u.dval = (double)ev->u.ulval; ev->et = ET_double; - return ev; + return true; case ET_hyper: ev->u.dval = (double)ev->u.hval; ev->et = ET_double; - return ev; + return true; case ET_uhyper: if ((double)ev->u.dval > FLT_MAX || (double)ev->u.dval < -FLT_MAX) - return NULL; + return false; ev->u.dval = (double)ev->u.ulval; ev->et = ET_double; - return ev; + return true; case ET_boolean: ev->u.dval = ev->u.bval ? 1.0 : 0.0; ev->et = ET_double; - return ev; + return true; case ET_float: ev->u.dval = (double)ev->u.fval; ev->et = ET_double; - return ev; + return true; case ET_double: - return ev; + return true; case ET_byte: ev->u.dval = (double)ev->u.byval; ev->et = ET_double; - return ev; + return true; default: OSL_ASSERT(false); - return NULL; + return false; } case ET_byte: switch (ev->et) { case ET_short: if (ev->u.sval < SAL_MIN_INT8 || ev->u.sval > SAL_MAX_UINT8) - return NULL; + return false; ev->u.byval = (unsigned char)ev->u.sval; ev->et = ET_byte; - return ev; + return true; case ET_ushort: if (ev->u.usval > SAL_MAX_UINT8) - return NULL; + return false; ev->u.byval = (unsigned char)ev->u.usval; ev->et = ET_byte; - return ev; + return true; case ET_long: if (ev->u.lval < SAL_MIN_INT8 || ev->u.lval > SAL_MAX_UINT8) - return NULL; + return false; ev->u.byval = (unsigned char) ev->u.lval; ev->et = ET_byte; - return ev; + return true; case ET_ulong: if (ev->u.ulval > SAL_MAX_UINT8) - return NULL; + return false; ev->u.byval = (unsigned char) ev->u.ulval; ev->et = ET_byte; - return ev; + return true; case ET_hyper: if (ev->u.hval < SAL_MIN_INT8 || ev->u.hval > SAL_MAX_UINT8) - return NULL; + return false; ev->u.byval = (unsigned char) ev->u.hval; ev->et = ET_byte; - return ev; + return true; case ET_uhyper: if (ev->u.uhval > SAL_MAX_UINT8) - return NULL; + return false; ev->u.byval = (unsigned char) ev->u.uhval; ev->et = ET_byte; - return ev; + return true; case ET_boolean: ev->u.byval = ev->u.bval ? 1 : 0; ev->et = ET_byte; - return ev; + return true; case ET_float: if (ev->u.fval < SAL_MIN_INT8 || ev->u.fval > SAL_MAX_UINT8) - return NULL; + return false; ev->u.byval = (unsigned char) ev->u.fval; ev->et = ET_byte; - return ev; + return true; case ET_double: if (ev->u.dval < SAL_MIN_INT8 || ev->u.dval > SAL_MAX_UINT8) - return NULL; + return false; ev->u.byval = (unsigned char) ev->u.dval; ev->et = ET_byte; - return ev; + return true; case ET_byte: - return ev; + return true; default: OSL_ASSERT(false); - return NULL; + return false; } default: OSL_ASSERT(false); - return NULL; + return false; } } @@ -747,14 +747,16 @@ AstExprValue* AstExpression::coerce(ExprType t, bool bAssign) break; } - AstExprValue* const coerced(coerce_value(copy, t)); - if (!coerced) + if (!coerce_value(copy, t)) + { delete copy; + copy = nullptr; + } if (bAssign) - m_exprValue = coerced; + m_exprValue = copy; - return coerced; + return copy; } void AstExpression::evaluate() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits