BASIC : Use std::vector in SbiRuntime to save references

Change-Id: Ica819538b39e58416825e651d057620a66f731cd
Reviewed-on: https://gerrit.libreoffice.org/23193
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Arnaud Versini <arnaud.versini@libreoffice.org>
This commit is contained in:
Arnaud Versini
2016-03-13 18:25:00 +01:00
committed by Arnaud Versini
parent e8aea8fd73
commit bb3930bb91
2 changed files with 4 additions and 48 deletions

View File

@@ -210,16 +210,6 @@ public:
LanguageType* peFormatterLangType=nullptr, DateFormat* peFormatterDateFormat=nullptr );
};
// chainable items to keep references temporary
struct RefSaveItem
{
SbxVariableRef xRef;
RefSaveItem* pNext;
RefSaveItem() { pNext = nullptr; }
};
// There's one instance of this class for every executed sub-program.
// This instance is the heart of the BASIC-machine and contains only local data.
@@ -274,30 +264,7 @@ class SbiRuntime
sal_uInt16 nOps; // opcode counter
sal_uInt32 m_nLastTime;
RefSaveItem* pRefSaveList; // #74254 save temporary references
RefSaveItem* pItemStoreList; // keep unused items
void SaveRef( SbxVariable* pVar )
{
RefSaveItem* pItem = pItemStoreList;
if( pItem )
pItemStoreList = pItem->pNext;
else
pItem = new RefSaveItem();
pItem->pNext = pRefSaveList;
pItem->xRef = pVar;
pRefSaveList = pItem;
}
void ClearRefs()
{
while( pRefSaveList )
{
RefSaveItem* pToClearItem = pRefSaveList;
pRefSaveList = pToClearItem->pNext;
pToClearItem->xRef = nullptr;
pToClearItem->pNext = pItemStoreList;
pItemStoreList = pToClearItem;
}
}
std::vector<SbxVariableRef> aRefSaved; // #74254 save temporary references
SbxVariable* FindElement
( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt32 nOp2, SbError, bool bLocal, bool bStatic = false );

View File

@@ -593,8 +593,6 @@ SbiRuntime::SbiRuntime( SbModule* pm, SbMethod* pe, sal_uInt32 nStart )
refExprStk = new SbxArray;
SetVBAEnabled( pMod->IsVBACompat() );
SetParameters( pe ? pe->GetParameters() : nullptr );
pRefSaveList = nullptr;
pItemStoreList = nullptr;
}
SbiRuntime::~SbiRuntime()
@@ -602,15 +600,6 @@ SbiRuntime::~SbiRuntime()
ClearGosubStack();
ClearArgvStack();
ClearForStack();
// #74254 free items for saving temporary references
ClearRefs();
while( pItemStoreList )
{
RefSaveItem* pToDeleteItem = pItemStoreList;
pItemStoreList = pToDeleteItem->pNext;
delete pToDeleteItem;
}
}
void SbiRuntime::SetVBAEnabled(bool bEnabled )
@@ -4038,7 +4027,7 @@ void SbiRuntime::StepELEM( sal_uInt32 nOp1, sal_uInt32 nOp2 )
// #74254 now per list
if( pObj )
{
SaveRef( static_cast<SbxVariable*>(pObj) );
aRefSaved.push_back( pObj );
}
PushVar( FindElement( pObj, nOp1, nOp2, ERRCODE_BASIC_NO_METHOD, false ) );
}
@@ -4118,7 +4107,7 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 )
else if( t != SbxVARIANT && (SbxDataType)(p->GetType() & 0x0FFF ) != t )
{
SbxVariable* q = new SbxVariable( t );
SaveRef( q );
aRefSaved.push_back( q );
*q = *p;
p = q;
if ( i )
@@ -4212,7 +4201,7 @@ void SbiRuntime::StepSTMNT( sal_uInt32 nOp1, sal_uInt32 nOp2 )
ClearExprStack();
ClearRefs();
aRefSaved.clear();
// We have to cancel hard here because line and column
// would be wrong later otherwise!