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>
diff --git a/basic/qa/vba_tests/typename.vb b/basic/qa/vba_tests/typename.vb
index 4ec2f3e..7e49a4d 100644
--- a/basic/qa/vba_tests/typename.vb
+++ b/basic/qa/vba_tests/typename.vb
@@ -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
diff --git a/basic/source/comp/exprgen.cxx b/basic/source/comp/exprgen.cxx
old mode 100644
new mode 100755
index d1ebb48..3981bef
--- a/basic/source/comp/exprgen.cxx
+++ b/basic/source/comp/exprgen.cxx
@@ -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 );
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
old mode 100644
new mode 100755
index d2cb9fe..3a9cb95
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -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!)