tdf#129596 Distinguish between integer and long while loading immediate values

During the generation of CONST_ expressions, distinguish between
integer and long and load the correct value in the immediate load step.

Change-Id: Ib4eb65d7fae3163043899ad8234816b1ebd7316b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85779
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
U-DESKTOP-8OSNV7R\DrRobotto 2019-12-24 12:22:34 +01:00 committed by Mike Kaganski
parent 5fbc89478e
commit 0b4f8bf571
3 changed files with 21 additions and 3 deletions

View file

@ -61,6 +61,12 @@ Function verify_testTypeName() As String
date1 = TypeName(l1)
TestLog_ASSERT date1 = date2, "the return TypeName is: " & date1
' tdf#129596 - Types of constant values
TestLog_ASSERT TypeName(32767) = "Integer", "the return TypeName(32767) is: " & TypeName(32767)
TestLog_ASSERT TypeName(-32767) = "Integer", "the return TypeName(-32767) is: " & TypeName(-32767)
TestLog_ASSERT TypeName(1048575) = "Long", "the return TypeName(1048575) is: " & TypeName(1048575)
TestLog_ASSERT TypeName(-1048575) = "Long", "the return TypeName(-1048575) is: " & TypeName(-1048575)
result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
verify_testTypeName = result

4
basic/source/comp/exprgen.cxx Normal file → Executable file
View file

@ -72,8 +72,10 @@ void SbiExprNode::Gen( SbiCodeGen& rGen, RecursiveMode eRecMode )
case SbxEMPTY:
rGen.Gen( SbiOpcode::EMPTY_ );
break;
case SbxLONG:
case SbxINTEGER:
rGen.Gen( SbiOpcode::CONST_, static_cast<short>(nVal) );
nStringId = rGen.GetParser()->aGblStrings.Add(nVal, eType);
rGen.Gen( SbiOpcode::CONST_, nStringId );
break;
case SbxSTRING:
nStringId = rGen.GetParser()->aGblStrings.Add( aStrVal );

14
basic/source/runtime/runtime.cxx Normal file → Executable file
View file

@ -2803,8 +2803,18 @@ void SbiRuntime::StepLOADSC( sal_uInt32 nOp1 )
void SbiRuntime::StepLOADI( sal_uInt32 nOp1 )
{
SbxVariable* p = new SbxVariable;
p->PutInteger( static_cast<sal_Int16>( nOp1 ) );
PushVar( p );
OUString aStr = pImg->GetString(static_cast<short>(nOp1));
double n = ::rtl::math::stringToDouble(aStr, '.', ',');
if (n >= SbxMININT && n <= SbxMAXINT)
{
p->PutInteger(static_cast<sal_Int16>(n));
}
else
{
p->PutLong(static_cast<sal_Int32>(n));
}
PushVar(p);
}
// store a named argument in Argv (+Arg-no. from 1!)