diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-18 14:35:43 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-19 08:30:49 +0200 |
commit | 8b0a69498b025e13d9772689e9e4fa3d6b05e609 (patch) | |
tree | 5fce654b3e02cd08d85dc95655c97d7181517687 /basic/source/comp | |
parent | 5dccf84b14ed0e09262411295c5880f787342d59 (diff) |
loplugin:flatten in basic
Change-Id: Icb8e3cda312b50c9a9f12f96bec1c746f41c8979
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92483
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic/source/comp')
-rw-r--r-- | basic/source/comp/buffer.cxx | 42 | ||||
-rw-r--r-- | basic/source/comp/dim.cxx | 198 | ||||
-rw-r--r-- | basic/source/comp/exprgen.cxx | 76 | ||||
-rw-r--r-- | basic/source/comp/exprnode.cxx | 336 | ||||
-rw-r--r-- | basic/source/comp/parser.cxx | 70 | ||||
-rw-r--r-- | basic/source/comp/symtbl.cxx | 80 |
6 files changed, 401 insertions, 401 deletions
diff --git a/basic/source/comp/buffer.cxx b/basic/source/comp/buffer.cxx index a7dca978b27a..80017fcca354 100644 --- a/basic/source/comp/buffer.cxx +++ b/basic/source/comp/buffer.cxx @@ -124,29 +124,29 @@ void SbiBuffer::Patch( sal_uInt32 off, sal_uInt32 val ) void SbiBuffer::Chain( sal_uInt32 off ) { - if( off && pBuf ) + if( !(off && pBuf) ) + return; + + sal_uInt8 *ip; + sal_uInt32 i = off; + sal_uInt32 val1 = (nOff & 0xFFFF); + sal_uInt32 val2 = (nOff >> 16); + do { - sal_uInt8 *ip; - sal_uInt32 i = off; - sal_uInt32 val1 = (nOff & 0xFFFF); - sal_uInt32 val2 = (nOff >> 16); - do + ip = reinterpret_cast<sal_uInt8*>(pBuf.get()) + i; + sal_uInt8* pTmp = ip; + i = *pTmp++; i |= *pTmp++ << 8; i |= *pTmp++ << 16; i |= *pTmp++ << 24; + + if( i >= nOff ) { - ip = reinterpret_cast<sal_uInt8*>(pBuf.get()) + i; - sal_uInt8* pTmp = ip; - i = *pTmp++; i |= *pTmp++ << 8; i |= *pTmp++ << 16; i |= *pTmp++ << 24; - - if( i >= nOff ) - { - pParser->Error( ERRCODE_BASIC_INTERNAL_ERROR, "BACKCHAIN" ); - break; - } - *ip++ = static_cast<char>( val1 & 0xFF ); - *ip++ = static_cast<char>( val1 >> 8 ); - *ip++ = static_cast<char>( val2 & 0xFF ); - *ip = static_cast<char>( val2 >> 8 ); - } while( i ); - } + pParser->Error( ERRCODE_BASIC_INTERNAL_ERROR, "BACKCHAIN" ); + break; + } + *ip++ = static_cast<char>( val1 & 0xFF ); + *ip++ = static_cast<char>( val1 >> 8 ); + *ip++ = static_cast<char>( val2 & 0xFF ); + *ip = static_cast<char>( val2 >> 8 ); + } while( i ); } void SbiBuffer::operator +=( sal_Int8 n ) diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx index 0689e421e533..211d4e325f5b 100644 --- a/basic/source/comp/dim.cxx +++ b/basic/source/comp/dim.cxx @@ -79,116 +79,116 @@ SbiSymDef* SbiParser::VarDecl( SbiExprListPtr* ppDim, bool bStatic, bool bConst void SbiParser::TypeDecl( SbiSymDef& rDef, bool bAsNewAlreadyParsed ) { SbxDataType eType = rDef.GetType(); - if( bAsNewAlreadyParsed || Peek() == AS ) + if( !(bAsNewAlreadyParsed || Peek() == AS) ) + return; + + short nSize = 0; + if( !bAsNewAlreadyParsed ) + Next(); + rDef.SetDefinedAs(); + SbiToken eTok = Next(); + if( !bAsNewAlreadyParsed && eTok == NEW ) { - short nSize = 0; - if( !bAsNewAlreadyParsed ) - Next(); - rDef.SetDefinedAs(); - SbiToken eTok = Next(); - if( !bAsNewAlreadyParsed && eTok == NEW ) - { - rDef.SetNew(); - eTok = Next(); - } - switch( eTok ) - { - case ANY: - if( rDef.IsNew() ) - Error( ERRCODE_BASIC_SYNTAX ); - eType = SbxVARIANT; break; - case TINTEGER: - case TLONG: - case TSINGLE: - case TDOUBLE: - case TCURRENCY: - case TDATE: - case TSTRING: - case TOBJECT: - case ERROR_: - case TBOOLEAN: - case TVARIANT: - case TBYTE: - if( rDef.IsNew() ) - Error( ERRCODE_BASIC_SYNTAX ); - eType = (eTok==TBYTE) ? SbxBYTE : SbxDataType( eTok - TINTEGER + SbxINTEGER ); - if( eType == SbxSTRING ) - { - // STRING*n ? - if( Peek() == MUL ) - { // fixed size! - Next(); - SbiConstExpression aSize( this ); - nSize = aSize.GetShortValue(); - if( nSize < 0 || (bVBASupportOn && nSize <= 0) ) - Error( ERRCODE_BASIC_OUT_OF_RANGE ); - else - rDef.SetFixedStringLength( nSize ); - } + rDef.SetNew(); + eTok = Next(); + } + switch( eTok ) + { + case ANY: + if( rDef.IsNew() ) + Error( ERRCODE_BASIC_SYNTAX ); + eType = SbxVARIANT; break; + case TINTEGER: + case TLONG: + case TSINGLE: + case TDOUBLE: + case TCURRENCY: + case TDATE: + case TSTRING: + case TOBJECT: + case ERROR_: + case TBOOLEAN: + case TVARIANT: + case TBYTE: + if( rDef.IsNew() ) + Error( ERRCODE_BASIC_SYNTAX ); + eType = (eTok==TBYTE) ? SbxBYTE : SbxDataType( eTok - TINTEGER + SbxINTEGER ); + if( eType == SbxSTRING ) + { + // STRING*n ? + if( Peek() == MUL ) + { // fixed size! + Next(); + SbiConstExpression aSize( this ); + nSize = aSize.GetShortValue(); + if( nSize < 0 || (bVBASupportOn && nSize <= 0) ) + Error( ERRCODE_BASIC_OUT_OF_RANGE ); + else + rDef.SetFixedStringLength( nSize ); } - break; - case SYMBOL: // can only be a TYPE or an object class! - if( eScanType != SbxVARIANT ) - Error( ERRCODE_BASIC_SYNTAX ); - else - { - OUString aCompleteName = aSym; + } + break; + case SYMBOL: // can only be a TYPE or an object class! + if( eScanType != SbxVARIANT ) + Error( ERRCODE_BASIC_SYNTAX ); + else + { + OUString aCompleteName = aSym; - // #52709 DIM AS NEW for Uno with full-qualified name - if( Peek() == DOT ) + // #52709 DIM AS NEW for Uno with full-qualified name + if( Peek() == DOT ) + { + OUString aDotStr( '.' ); + while( Peek() == DOT ) { - OUString aDotStr( '.' ); - while( Peek() == DOT ) + aCompleteName += aDotStr; + Next(); + SbiToken ePeekTok = Peek(); + if( ePeekTok == SYMBOL || IsKwd( ePeekTok ) ) { - aCompleteName += aDotStr; Next(); - SbiToken ePeekTok = Peek(); - if( ePeekTok == SYMBOL || IsKwd( ePeekTok ) ) - { - Next(); - aCompleteName += aSym; - } - else - { - Next(); - Error( ERRCODE_BASIC_UNEXPECTED, SYMBOL ); - break; - } + aCompleteName += aSym; + } + else + { + Next(); + Error( ERRCODE_BASIC_UNEXPECTED, SYMBOL ); + break; } } - else if( rEnumArray->Find( aCompleteName, SbxClassType::Object ) || ( IsVBASupportOn() && VBAConstantHelper::instance().isVBAConstantType( aCompleteName ) ) ) - { - eType = SbxLONG; - break; - } + } + else if( rEnumArray->Find( aCompleteName, SbxClassType::Object ) || ( IsVBASupportOn() && VBAConstantHelper::instance().isVBAConstantType( aCompleteName ) ) ) + { + eType = SbxLONG; + break; + } - // Take over in the string pool - rDef.SetTypeId( aGblStrings.Add( aCompleteName ) ); + // Take over in the string pool + rDef.SetTypeId( aGblStrings.Add( aCompleteName ) ); - if( rDef.IsNew() && pProc == nullptr ) - aRequiredTypes.push_back( aCompleteName ); - } - eType = SbxOBJECT; - break; - case FIXSTRING: // new syntax for complex UNO types - rDef.SetTypeId( aGblStrings.Add( aSym ) ); - eType = SbxOBJECT; - break; - default: - Error( ERRCODE_BASIC_UNEXPECTED, eTok ); - Next(); - } - // The variable could have been declared with a suffix - if( rDef.GetType() != SbxVARIANT ) - { - if( rDef.GetType() != eType ) - Error( ERRCODE_BASIC_VAR_DEFINED, rDef.GetName() ); - else if( eType == SbxSTRING && rDef.GetLen() != nSize ) - Error( ERRCODE_BASIC_VAR_DEFINED, rDef.GetName() ); - } - rDef.SetType( eType ); - rDef.SetLen( nSize ); + if( rDef.IsNew() && pProc == nullptr ) + aRequiredTypes.push_back( aCompleteName ); + } + eType = SbxOBJECT; + break; + case FIXSTRING: // new syntax for complex UNO types + rDef.SetTypeId( aGblStrings.Add( aSym ) ); + eType = SbxOBJECT; + break; + default: + Error( ERRCODE_BASIC_UNEXPECTED, eTok ); + Next(); + } + // The variable could have been declared with a suffix + if( rDef.GetType() != SbxVARIANT ) + { + if( rDef.GetType() != eType ) + Error( ERRCODE_BASIC_VAR_DEFINED, rDef.GetName() ); + else if( eType == SbxSTRING && rDef.GetLen() != nSize ) + Error( ERRCODE_BASIC_VAR_DEFINED, rDef.GetName() ); } + rDef.SetType( eType ); + rDef.SetLen( nSize ); } // Here variables, arrays and structures were defined. diff --git a/basic/source/comp/exprgen.cxx b/basic/source/comp/exprgen.cxx index 6c60c02b0d7e..2baf28a803e3 100644 --- a/basic/source/comp/exprgen.cxx +++ b/basic/source/comp/exprgen.cxx @@ -210,49 +210,49 @@ void SbiExprNode::GenElement( SbiCodeGen& rGen, SbiOpcode eOp ) void SbiExprList::Gen(SbiCodeGen& rGen) { - if( !aData.empty() ) - { - rGen.Gen( SbiOpcode::ARGC_ ); - // Type adjustment at DECLARE + if( aData.empty() ) + return; - for( auto& pExpr: aData ) - { - pExpr->Gen(); - if( !pExpr->GetName().isEmpty() ) - { - // named arg - sal_uInt16 nSid = rGen.GetParser()->aGblStrings.Add( pExpr->GetName() ); - rGen.Gen( SbiOpcode::ARGN_, nSid ); + rGen.Gen( SbiOpcode::ARGC_ ); + // Type adjustment at DECLARE - /* TODO: Check after Declare concept change - // From 1996-01-10: Type adjustment at named -> search suitable parameter - if( pProc ) - { - // For the present: trigger an error - pParser->Error( ERRCODE_BASIC_NO_NAMED_ARGS ); + for( auto& pExpr: aData ) + { + pExpr->Gen(); + if( !pExpr->GetName().isEmpty() ) + { + // named arg + sal_uInt16 nSid = rGen.GetParser()->aGblStrings.Add( pExpr->GetName() ); + rGen.Gen( SbiOpcode::ARGN_, nSid ); - // Later, if Named Args at DECLARE is possible - //for( sal_uInt16 i = 1 ; i < nParAnz ; i++ ) - //{ - // SbiSymDef* pDef = pPool->Get( i ); - // const String& rName = pDef->GetName(); - // if( rName.Len() ) - // { - // if( pExpr->GetName().ICompare( rName ) - // == COMPARE_EQUAL ) - // { - // pParser->aGen.Gen( ARGTYP_, pDef->GetType() ); - // break; - // } - // } - //} - } - */ - } - else + /* TODO: Check after Declare concept change + // From 1996-01-10: Type adjustment at named -> search suitable parameter + if( pProc ) { - rGen.Gen( SbiOpcode::ARGV_ ); + // For the present: trigger an error + pParser->Error( ERRCODE_BASIC_NO_NAMED_ARGS ); + + // Later, if Named Args at DECLARE is possible + //for( sal_uInt16 i = 1 ; i < nParAnz ; i++ ) + //{ + // SbiSymDef* pDef = pPool->Get( i ); + // const String& rName = pDef->GetName(); + // if( rName.Len() ) + // { + // if( pExpr->GetName().ICompare( rName ) + // == COMPARE_EQUAL ) + // { + // pParser->aGen.Gen( ARGTYP_, pDef->GetType() ); + // break; + // } + // } + //} } + */ + } + else + { + rGen.Gen( SbiOpcode::ARGV_ ); } } } diff --git a/basic/source/comp/exprnode.cxx b/basic/source/comp/exprnode.cxx index 9e4c6ea2e6b3..8fb38b44eeb6 100644 --- a/basic/source/comp/exprnode.cxx +++ b/basic/source/comp/exprnode.cxx @@ -232,189 +232,189 @@ void SbiExprNode::FoldConstantsBinaryNode(SbiParser* pParser) { pLeft->FoldConstants(pParser); pRight->FoldConstants(pParser); - if( pLeft->IsConstant() && pRight->IsConstant() - && pLeft->eNodeType == pRight->eNodeType ) + if( !(pLeft->IsConstant() && pRight->IsConstant() + && pLeft->eNodeType == pRight->eNodeType) ) + return; + + CollectBits(); + if( eTok == CAT ) + // CAT affiliate also two numbers! + eType = SbxSTRING; + if( pLeft->eType == SbxSTRING ) + // No Type Mismatch! + eType = SbxSTRING; + if( eType == SbxSTRING ) { - CollectBits(); - if( eTok == CAT ) - // CAT affiliate also two numbers! - eType = SbxSTRING; - if( pLeft->eType == SbxSTRING ) - // No Type Mismatch! + OUString rl( pLeft->GetString() ); + OUString rr( pRight->GetString() ); + pLeft.reset(); + pRight.reset(); + if( eTok == PLUS || eTok == CAT ) + { + eTok = CAT; + // Linking: + aStrVal = rl; + aStrVal += rr; eType = SbxSTRING; - if( eType == SbxSTRING ) + eNodeType = SbxSTRVAL; + } + else { - OUString rl( pLeft->GetString() ); - OUString rr( pRight->GetString() ); - pLeft.reset(); - pRight.reset(); - if( eTok == PLUS || eTok == CAT ) + eType = SbxDOUBLE; + eNodeType = SbxNUMVAL; + int eRes = rr.compareTo( rl ); + switch( eTok ) { - eTok = CAT; - // Linking: - aStrVal = rl; - aStrVal += rr; - eType = SbxSTRING; - eNodeType = SbxSTRVAL; + case EQ: + nVal = ( eRes == 0 ) ? SbxTRUE : SbxFALSE; + break; + case NE: + nVal = ( eRes != 0 ) ? SbxTRUE : SbxFALSE; + break; + case LT: + nVal = ( eRes < 0 ) ? SbxTRUE : SbxFALSE; + break; + case GT: + nVal = ( eRes > 0 ) ? SbxTRUE : SbxFALSE; + break; + case LE: + nVal = ( eRes <= 0 ) ? SbxTRUE : SbxFALSE; + break; + case GE: + nVal = ( eRes >= 0 ) ? SbxTRUE : SbxFALSE; + break; + default: + pParser->Error( ERRCODE_BASIC_CONVERSION ); + bError = true; + break; } - else + } + } + else + { + double nl = pLeft->nVal; + double nr = pRight->nVal; + long ll = 0, lr = 0; + long llMod = 0, lrMod = 0; + if( ( eTok >= AND && eTok <= IMP ) + || eTok == IDIV || eTok == MOD ) + { + // Integer operations + bool bErr = false; + if( nl > SbxMAXLNG ) { - eType = SbxDOUBLE; - eNodeType = SbxNUMVAL; - int eRes = rr.compareTo( rl ); - switch( eTok ) - { - case EQ: - nVal = ( eRes == 0 ) ? SbxTRUE : SbxFALSE; - break; - case NE: - nVal = ( eRes != 0 ) ? SbxTRUE : SbxFALSE; - break; - case LT: - nVal = ( eRes < 0 ) ? SbxTRUE : SbxFALSE; - break; - case GT: - nVal = ( eRes > 0 ) ? SbxTRUE : SbxFALSE; - break; - case LE: - nVal = ( eRes <= 0 ) ? SbxTRUE : SbxFALSE; - break; - case GE: - nVal = ( eRes >= 0 ) ? SbxTRUE : SbxFALSE; - break; - default: - pParser->Error( ERRCODE_BASIC_CONVERSION ); - bError = true; - break; - } + bErr = true; + nl = SbxMAXLNG; + } + else if( nl < SbxMINLNG ) + { + bErr = true; + nl = SbxMINLNG; + } + if( nr > SbxMAXLNG ) + { + bErr = true; + nr = SbxMAXLNG; + } + else if( nr < SbxMINLNG ) + { + bErr = true; + nr = SbxMINLNG; + } + ll = static_cast<long>(nl); lr = static_cast<long>(nr); + llMod = static_cast<long>(nl); + lrMod = static_cast<long>(nr); + if( bErr ) + { + pParser->Error( ERRCODE_BASIC_MATH_OVERFLOW ); + bError = true; } } - else + bool bBothInt = ( pLeft->eType < SbxSINGLE + && pRight->eType < SbxSINGLE ); + pLeft.reset(); + pRight.reset(); + nVal = 0; + eType = SbxDOUBLE; + eNodeType = SbxNUMVAL; + bool bCheckType = false; + switch( eTok ) { - double nl = pLeft->nVal; - double nr = pRight->nVal; - long ll = 0, lr = 0; - long llMod = 0, lrMod = 0; - if( ( eTok >= AND && eTok <= IMP ) - || eTok == IDIV || eTok == MOD ) - { - // Integer operations - bool bErr = false; - if( nl > SbxMAXLNG ) - { - bErr = true; - nl = SbxMAXLNG; - } - else if( nl < SbxMINLNG ) + case EXPON: + nVal = pow( nl, nr ); break; + case MUL: + bCheckType = true; + nVal = nl * nr; break; + case DIV: + if( !nr ) { - bErr = true; - nl = SbxMINLNG; - } - if( nr > SbxMAXLNG ) - { - bErr = true; - nr = SbxMAXLNG; - } - else if( nr < SbxMINLNG ) + pParser->Error( ERRCODE_BASIC_ZERODIV ); nVal = HUGE_VAL; + bError = true; + } else nVal = nl / nr; + break; + case PLUS: + bCheckType = true; + nVal = nl + nr; break; + case MINUS: + bCheckType = true; + nVal = nl - nr; break; + case EQ: + nVal = ( nl == nr ) ? SbxTRUE : SbxFALSE; + eType = SbxINTEGER; break; + case NE: + nVal = ( nl != nr ) ? SbxTRUE : SbxFALSE; + eType = SbxINTEGER; break; + case LT: + nVal = ( nl < nr ) ? SbxTRUE : SbxFALSE; + eType = SbxINTEGER; break; + case GT: + nVal = ( nl > nr ) ? SbxTRUE : SbxFALSE; + eType = SbxINTEGER; break; + case LE: + nVal = ( nl <= nr ) ? SbxTRUE : SbxFALSE; + eType = SbxINTEGER; break; + case GE: + nVal = ( nl >= nr ) ? SbxTRUE : SbxFALSE; + eType = SbxINTEGER; break; + case IDIV: + if( !lr ) { - bErr = true; - nr = SbxMINLNG; - } - ll = static_cast<long>(nl); lr = static_cast<long>(nr); - llMod = static_cast<long>(nl); - lrMod = static_cast<long>(nr); - if( bErr ) + pParser->Error( ERRCODE_BASIC_ZERODIV ); nVal = HUGE_VAL; + bError = true; + } else nVal = ll / lr; + eType = SbxLONG; break; + case MOD: + if( !lr ) { - pParser->Error( ERRCODE_BASIC_MATH_OVERFLOW ); + pParser->Error( ERRCODE_BASIC_ZERODIV ); nVal = HUGE_VAL; bError = true; - } - } - bool bBothInt = ( pLeft->eType < SbxSINGLE - && pRight->eType < SbxSINGLE ); - pLeft.reset(); - pRight.reset(); - nVal = 0; - eType = SbxDOUBLE; - eNodeType = SbxNUMVAL; - bool bCheckType = false; - switch( eTok ) - { - case EXPON: - nVal = pow( nl, nr ); break; - case MUL: - bCheckType = true; - nVal = nl * nr; break; - case DIV: - if( !nr ) - { - pParser->Error( ERRCODE_BASIC_ZERODIV ); nVal = HUGE_VAL; - bError = true; - } else nVal = nl / nr; - break; - case PLUS: - bCheckType = true; - nVal = nl + nr; break; - case MINUS: - bCheckType = true; - nVal = nl - nr; break; - case EQ: - nVal = ( nl == nr ) ? SbxTRUE : SbxFALSE; - eType = SbxINTEGER; break; - case NE: - nVal = ( nl != nr ) ? SbxTRUE : SbxFALSE; - eType = SbxINTEGER; break; - case LT: - nVal = ( nl < nr ) ? SbxTRUE : SbxFALSE; - eType = SbxINTEGER; break; - case GT: - nVal = ( nl > nr ) ? SbxTRUE : SbxFALSE; - eType = SbxINTEGER; break; - case LE: - nVal = ( nl <= nr ) ? SbxTRUE : SbxFALSE; - eType = SbxINTEGER; break; - case GE: - nVal = ( nl >= nr ) ? SbxTRUE : SbxFALSE; - eType = SbxINTEGER; break; - case IDIV: - if( !lr ) - { - pParser->Error( ERRCODE_BASIC_ZERODIV ); nVal = HUGE_VAL; - bError = true; - } else nVal = ll / lr; - eType = SbxLONG; break; - case MOD: - if( !lr ) - { - pParser->Error( ERRCODE_BASIC_ZERODIV ); nVal = HUGE_VAL; - bError = true; - } else nVal = llMod - lrMod * (llMod/lrMod); - eType = SbxLONG; break; - case AND: - nVal = static_cast<double>( ll & lr ); eType = SbxLONG; break; - case OR: - nVal = static_cast<double>( ll | lr ); eType = SbxLONG; break; - case XOR: - nVal = static_cast<double>( ll ^ lr ); eType = SbxLONG; break; - case EQV: - nVal = static_cast<double>( ~ll ^ lr ); eType = SbxLONG; break; - case IMP: - nVal = static_cast<double>( ~ll | lr ); eType = SbxLONG; break; - default: break; - } + } else nVal = llMod - lrMod * (llMod/lrMod); + eType = SbxLONG; break; + case AND: + nVal = static_cast<double>( ll & lr ); eType = SbxLONG; break; + case OR: + nVal = static_cast<double>( ll | lr ); eType = SbxLONG; break; + case XOR: + nVal = static_cast<double>( ll ^ lr ); eType = SbxLONG; break; + case EQV: + nVal = static_cast<double>( ~ll ^ lr ); eType = SbxLONG; break; + case IMP: + nVal = static_cast<double>( ~ll | lr ); eType = SbxLONG; break; + default: break; + } - if( !std::isfinite( nVal ) ) - pParser->Error( ERRCODE_BASIC_MATH_OVERFLOW ); + if( !std::isfinite( nVal ) ) + pParser->Error( ERRCODE_BASIC_MATH_OVERFLOW ); - // Recover the data type to kill rounding error - if( bCheckType && bBothInt - && nVal >= SbxMINLNG && nVal <= SbxMAXLNG ) - { - // Decimal place away - long n = static_cast<long>(nVal); - nVal = n; - eType = ( n >= SbxMININT && n <= SbxMAXINT ) - ? SbxINTEGER : SbxLONG; - } + // Recover the data type to kill rounding error + if( bCheckType && bBothInt + && nVal >= SbxMINLNG && nVal <= SbxMAXLNG ) + { + // Decimal place away + long n = static_cast<long>(nVal); + nVal = n; + eType = ( n >= SbxMININT && n <= SbxMAXINT ) + ? SbxINTEGER : SbxLONG; } } diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx index 45cf7e358fe6..c2b6329e44eb 100644 --- a/basic/source/comp/parser.cxx +++ b/basic/source/comp/parser.cxx @@ -211,19 +211,19 @@ void SbiParser::OpenBlock( SbiToken eTok, SbiExprNode* pVar ) void SbiParser::CloseBlock() { - if( pStack ) - { - SbiParseStack* p = pStack; + if( !pStack ) + return; - // #29955 service the for-loop level - if( p->eExitTok == FOR ) - aGen.DecForLevel(); + SbiParseStack* p = pStack; - aGen.BackChain( p->nChain ); - pStack = p->pNext; - pWithVar = p->pWithVar; - delete p; - } + // #29955 service the for-loop level + if( p->eExitTok == FOR ) + aGen.DecForLevel(); + + aGen.BackChain( p->nChain ); + pStack = p->pNext; + pWithVar = p->pWithVar; + delete p; } // EXIT ... @@ -525,37 +525,37 @@ void SbiParser::Symbol( const KeywordSymbolInfo* pKeywordSymbolInfo ) } } aVar.Gen( eRecMode ); - if( !bSpecialMidHandling ) + if( bSpecialMidHandling ) + return; + + if( !bEQ ) { - if( !bEQ ) - { - aGen.Gen( SbiOpcode::GET_ ); - } - else + aGen.Gen( SbiOpcode::GET_ ); + } + else + { + // so it must be an assignment! + if( !aVar.IsLvalue() ) + Error( ERRCODE_BASIC_LVALUE_EXPECTED ); + TestToken( EQ ); + SbiExpression aExpr( this ); + aExpr.Gen(); + SbiOpcode eOp = SbiOpcode::PUT_; + if( pDef ) { - // so it must be an assignment! - if( !aVar.IsLvalue() ) - Error( ERRCODE_BASIC_LVALUE_EXPECTED ); - TestToken( EQ ); - SbiExpression aExpr( this ); - aExpr.Gen(); - SbiOpcode eOp = SbiOpcode::PUT_; - if( pDef ) + if( pDef->GetConstDef() ) + Error( ERRCODE_BASIC_DUPLICATE_DEF, pDef->GetName() ); + if( pDef->GetType() == SbxOBJECT ) { - if( pDef->GetConstDef() ) - Error( ERRCODE_BASIC_DUPLICATE_DEF, pDef->GetName() ); - if( pDef->GetType() == SbxOBJECT ) + eOp = SbiOpcode::SET_; + if( pDef->GetTypeId() ) { - eOp = SbiOpcode::SET_; - if( pDef->GetTypeId() ) - { - aGen.Gen( SbiOpcode::SETCLASS_, pDef->GetTypeId() ); - return; - } + aGen.Gen( SbiOpcode::SETCLASS_, pDef->GetTypeId() ); + return; } } - aGen.Gen( eOp ); } + aGen.Gen( eOp ); } } diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx index 8385a31a3fdd..00a857abad6a 100644 --- a/basic/source/comp/symtbl.cxx +++ b/basic/source/comp/symtbl.cxx @@ -132,39 +132,39 @@ SbiProcDef* SbiSymPool::AddProc( const OUString& rName ) void SbiSymPool::Add( SbiSymDef* pDef ) { - if( pDef && pDef->pIn != this ) + if( !(pDef && pDef->pIn != this) ) + return; + + if( pDef->pIn ) { - if( pDef->pIn ) - { #ifdef DBG_UTIL - pParser->Error( ERRCODE_BASIC_INTERNAL_ERROR, "Dbl Pool" ); + pParser->Error( ERRCODE_BASIC_INTERNAL_ERROR, "Dbl Pool" ); #endif - return; - } + return; + } - pDef->nPos = m_Data.size(); - if( !pDef->nId ) + pDef->nPos = m_Data.size(); + if( !pDef->nId ) + { + // A unique name must be created in the string pool + // for static variables (Form ProcName:VarName) + OUString aName( pDef->aName ); + if( pDef->IsStatic() ) { - // A unique name must be created in the string pool - // for static variables (Form ProcName:VarName) - OUString aName( pDef->aName ); - if( pDef->IsStatic() ) - { - aName = pParser->aGblStrings.Find( nProcId ) - + ":" - + pDef->aName; - } - pDef->nId = rStrings.Add( aName ); + aName = pParser->aGblStrings.Find( nProcId ) + + ":" + + pDef->aName; } + pDef->nId = rStrings.Add( aName ); + } - if( !pDef->GetProcDef() ) - { - pDef->nProcId = nProcId; - } - pDef->pIn = this; - m_Data.insert( m_Data.begin() + pDef->nPos, std::unique_ptr<SbiSymDef>(pDef) ); + if( !pDef->GetProcDef() ) + { + pDef->nProcId = nProcId; } + pDef->pIn = this; + m_Data.insert( m_Data.begin() + pDef->nPos, std::unique_ptr<SbiSymDef>(pDef) ); } @@ -454,24 +454,24 @@ void SbiProcDef::Match( SbiProcDef* pOld ) void SbiProcDef::setPropertyMode( PropertyMode ePropMode ) { mePropMode = ePropMode; - if( mePropMode != PropertyMode::NONE ) - { - // Prop name = original scanned procedure name - maPropName = aName; + if( mePropMode == PropertyMode::NONE ) + return; - // CompleteProcName includes "Property xxx " - // to avoid conflicts with other symbols - OUString aCompleteProcName = "Property "; - switch( mePropMode ) - { - case PropertyMode::Get: aCompleteProcName += "Get "; break; - case PropertyMode::Let: aCompleteProcName += "Let "; break; - case PropertyMode::Set: aCompleteProcName += "Set "; break; - case PropertyMode::NONE: OSL_FAIL( "Illegal PropertyMode PropertyMode::NONE" ); break; - } - aCompleteProcName += aName; - aName = aCompleteProcName; + // Prop name = original scanned procedure name + maPropName = aName; + + // CompleteProcName includes "Property xxx " + // to avoid conflicts with other symbols + OUString aCompleteProcName = "Property "; + switch( mePropMode ) + { + case PropertyMode::Get: aCompleteProcName += "Get "; break; + case PropertyMode::Let: aCompleteProcName += "Let "; break; + case PropertyMode::Set: aCompleteProcName += "Set "; break; + case PropertyMode::NONE: OSL_FAIL( "Illegal PropertyMode PropertyMode::NONE" ); break; } + aCompleteProcName += aName; + aName = aCompleteProcName; } |