[Libreoffice-commits] core.git: basic/source

Arnaud Versini arnaud.versini at gmail.com
Wed Jan 27 07:37:34 PST 2016


 basic/source/comp/exprnode.cxx |    4 +---
 basic/source/comp/exprtree.cxx |    2 ++
 basic/source/inc/expr.hxx      |    4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 4cac0c05c645fbcc67cf6090144026a2dfd02064
Author: Arnaud Versini <arnaud.versini at gmail.com>
Date:   Sun Jan 24 18:59:33 2016 +0100

    BASIC: SbiExpression::IsIntConstant has side effects.
    
    Also renames IsIntConstant to ConvertToIntConstIfPossible.
    
    Change-Id: Ib4b465ac0d890762547fb2d83c26ad6be6ee75e8
    Reviewed-on: https://gerrit.libreoffice.org/21746
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/basic/source/comp/exprnode.cxx b/basic/source/comp/exprnode.cxx
index 19272dc..77c1aa5 100644
--- a/basic/source/comp/exprnode.cxx
+++ b/basic/source/comp/exprnode.cxx
@@ -152,7 +152,7 @@ SbiExprNode* SbiExprNode::GetRealNode()
 
 // This method transform the type, if it fits into the Integer range
 
-bool SbiExprNode::IsIntConst()
+void SbiExprNode::ConvertToIntConstIfPossible()
 {
     if( eNodeType == SbxNUMVAL )
     {
@@ -163,11 +163,9 @@ bool SbiExprNode::IsIntConst()
             {
                 nVal = (double) (short) nVal;
                 eType = SbxINTEGER;
-                return true;
             }
         }
     }
-    return false;
 }
 
 bool SbiExprNode::IsNumber()
diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx
index 634d5a3..5a153b3 100644
--- a/basic/source/comp/exprtree.cxx
+++ b/basic/source/comp/exprtree.cxx
@@ -1158,6 +1158,7 @@ SbiExprList* SbiExprList::ParseDimList( SbiParser* pParser )
             {
                 pExpr2 = new SbiExpression( pParser );
                 eTok = pParser->Next();
+                pExpr1->ConvertToIntConstIfPossible(), pExpr2->ConvertToIntConstIfPossible();
                 pExprList->bError = pExprList->bError || !pExpr1->IsValid() || !pExpr2->IsValid();
                 pExpr1->pNext = pExpr2;
                 if( !pLast )
@@ -1175,6 +1176,7 @@ SbiExprList* SbiExprList::ParseDimList( SbiParser* pParser )
             {
                 pExpr1->SetBased();
                 pExpr1->pNext = nullptr;
+                pExpr1->ConvertToIntConstIfPossible();
                 pExprList->bError = pExprList->bError || !pExpr1->IsValid();
                 if( !pLast )
                 {
diff --git a/basic/source/inc/expr.hxx b/basic/source/inc/expr.hxx
index 53a9638..eac1c8a 100644
--- a/basic/source/inc/expr.hxx
+++ b/basic/source/inc/expr.hxx
@@ -129,7 +129,7 @@ public:
     bool IsValid()                  { return !bError; }
     bool IsConstant()               // true: constant operand
         { return eNodeType == SbxSTRVAL || eNodeType == SbxNUMVAL; }
-    bool IsIntConst();
+    void ConvertToIntConstIfPossible();
     bool IsVariable();
     bool  IsUnary()
         { return pLeft && !pRight; }
@@ -197,7 +197,7 @@ public:
     bool IsValid()                  { return pExpr->IsValid();    }
     bool IsVariable()               { return pExpr->IsVariable(); }
     bool IsLvalue()                 { return pExpr->IsLvalue();   }
-    bool IsIntConstant()            { return pExpr->IsIntConst(); }
+    void ConvertToIntConstIfPossible() { pExpr->ConvertToIntConstIfPossible();     }
     const OUString& GetString()     { return pExpr->GetString();  }
     SbiSymDef* GetRealVar()         { return pExpr->GetRealVar(); }
     SbiExprNode* GetExprNode()      { return pExpr; }


More information about the Libreoffice-commits mailing list