BASIC : Use a vector to store the argv stack
Change-Id: I29c93aec598b7f784f549ce05f6b32dfabbfc3ad Reviewed-on: https://gerrit.libreoffice.org/23815 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Arnaud Versini <arnaud.versini@libreoffice.org>
This commit is contained in:
parent
82a04a8269
commit
c1e4d402c6
@ -40,7 +40,7 @@
|
||||
class SbiInstance; // active StarBASIC process
|
||||
class SbiRuntime; // active StarBASIC procedure instance
|
||||
|
||||
struct SbiArgvStack; // Argv stack element
|
||||
struct SbiArgv; // Argv stack element
|
||||
struct SbiGosub; // GOSUB stack element
|
||||
class SbiImage; // Code-Image
|
||||
class SbiIoSystem;
|
||||
@ -230,7 +230,6 @@ class SbiRuntime
|
||||
SbxVariableRef refRedim; // Array saved to use for REDIM
|
||||
SbxVariableRef xDummyVar; // substitute for variables that weren't found
|
||||
SbxVariable* mpExtCaller; // Caller ( external - e.g. button name, shape, range object etc. - only in vba mode )
|
||||
SbiArgvStack* pArgvStk; // ARGV-Stack
|
||||
SbiForStack* pForStk; // FOR/NEXT-Stack
|
||||
sal_uInt16 nExprLvl; // depth of the expr-stack
|
||||
sal_uInt16 nForLvl; // #118235: Maintain for level
|
||||
@ -258,6 +257,7 @@ class SbiRuntime
|
||||
|
||||
std::vector<SbxVariableRef> aRefSaved; // #74254 save temporary references
|
||||
std::vector<SbiGosub> pGosubStk; // GOSUB stack
|
||||
std::vector<SbiArgv> pArgvStk; // ARGV-Stack
|
||||
|
||||
|
||||
SbxVariable* FindElement
|
||||
|
@ -111,10 +111,13 @@ bool StarBASIC::isVBAEnabled()
|
||||
return false;
|
||||
}
|
||||
|
||||
struct SbiArgvStack { // Argv stack:
|
||||
SbiArgvStack* pNext; // Stack Chain
|
||||
struct SbiArgv { // Argv stack:
|
||||
SbxArrayRef refArgv; // Argv
|
||||
short nArgc; // Argc
|
||||
|
||||
SbiArgv(SbxArrayRef refArgv_, short nArgc_) :
|
||||
refArgv(refArgv_),
|
||||
nArgc(nArgc_) {}
|
||||
};
|
||||
|
||||
#define MAXRECURSION 500 //to prevent dead-recursions
|
||||
@ -577,7 +580,6 @@ SbiRuntime::SbiRuntime( SbModule* pm, SbMethod* pe, sal_uInt32 nStart )
|
||||
{
|
||||
nFlags = pe ? pe->GetDebugFlags() : 0;
|
||||
pIosys = pInst->GetIoSystem();
|
||||
pArgvStk = nullptr;
|
||||
pForStk = nullptr;
|
||||
pError = nullptr;
|
||||
pErrCode =
|
||||
@ -1080,31 +1082,25 @@ void SbiRuntime::PopGosub()
|
||||
|
||||
void SbiRuntime::PushArgv()
|
||||
{
|
||||
SbiArgvStack* p = new SbiArgvStack;
|
||||
p->refArgv = refArgv;
|
||||
p->nArgc = nArgc;
|
||||
pArgvStk.emplace_back(refArgv, nArgc);
|
||||
nArgc = 1;
|
||||
refArgv.Clear();
|
||||
p->pNext = pArgvStk;
|
||||
pArgvStk = p;
|
||||
}
|
||||
|
||||
void SbiRuntime::PopArgv()
|
||||
{
|
||||
if( pArgvStk )
|
||||
if( !pArgvStk.empty() )
|
||||
{
|
||||
SbiArgvStack* p = pArgvStk;
|
||||
pArgvStk = p->pNext;
|
||||
refArgv = p->refArgv;
|
||||
nArgc = p->nArgc;
|
||||
delete p;
|
||||
refArgv = pArgvStk.back().refArgv;
|
||||
nArgc = pArgvStk.back().nArgc;
|
||||
pArgvStk.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SbiRuntime::ClearArgvStack()
|
||||
{
|
||||
while( pArgvStk )
|
||||
while( !pArgvStk.empty() )
|
||||
{
|
||||
PopArgv();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user