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 SbiInstance; // active StarBASIC process
|
||||||
class SbiRuntime; // active StarBASIC procedure instance
|
class SbiRuntime; // active StarBASIC procedure instance
|
||||||
|
|
||||||
struct SbiArgvStack; // Argv stack element
|
struct SbiArgv; // Argv stack element
|
||||||
struct SbiGosub; // GOSUB stack element
|
struct SbiGosub; // GOSUB stack element
|
||||||
class SbiImage; // Code-Image
|
class SbiImage; // Code-Image
|
||||||
class SbiIoSystem;
|
class SbiIoSystem;
|
||||||
@ -230,7 +230,6 @@ class SbiRuntime
|
|||||||
SbxVariableRef refRedim; // Array saved to use for REDIM
|
SbxVariableRef refRedim; // Array saved to use for REDIM
|
||||||
SbxVariableRef xDummyVar; // substitute for variables that weren't found
|
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 )
|
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
|
SbiForStack* pForStk; // FOR/NEXT-Stack
|
||||||
sal_uInt16 nExprLvl; // depth of the expr-stack
|
sal_uInt16 nExprLvl; // depth of the expr-stack
|
||||||
sal_uInt16 nForLvl; // #118235: Maintain for level
|
sal_uInt16 nForLvl; // #118235: Maintain for level
|
||||||
@ -258,6 +257,7 @@ class SbiRuntime
|
|||||||
|
|
||||||
std::vector<SbxVariableRef> aRefSaved; // #74254 save temporary references
|
std::vector<SbxVariableRef> aRefSaved; // #74254 save temporary references
|
||||||
std::vector<SbiGosub> pGosubStk; // GOSUB stack
|
std::vector<SbiGosub> pGosubStk; // GOSUB stack
|
||||||
|
std::vector<SbiArgv> pArgvStk; // ARGV-Stack
|
||||||
|
|
||||||
|
|
||||||
SbxVariable* FindElement
|
SbxVariable* FindElement
|
||||||
|
@ -111,10 +111,13 @@ bool StarBASIC::isVBAEnabled()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SbiArgvStack { // Argv stack:
|
struct SbiArgv { // Argv stack:
|
||||||
SbiArgvStack* pNext; // Stack Chain
|
|
||||||
SbxArrayRef refArgv; // Argv
|
SbxArrayRef refArgv; // Argv
|
||||||
short nArgc; // Argc
|
short nArgc; // Argc
|
||||||
|
|
||||||
|
SbiArgv(SbxArrayRef refArgv_, short nArgc_) :
|
||||||
|
refArgv(refArgv_),
|
||||||
|
nArgc(nArgc_) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAXRECURSION 500 //to prevent dead-recursions
|
#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;
|
nFlags = pe ? pe->GetDebugFlags() : 0;
|
||||||
pIosys = pInst->GetIoSystem();
|
pIosys = pInst->GetIoSystem();
|
||||||
pArgvStk = nullptr;
|
|
||||||
pForStk = nullptr;
|
pForStk = nullptr;
|
||||||
pError = nullptr;
|
pError = nullptr;
|
||||||
pErrCode =
|
pErrCode =
|
||||||
@ -1080,31 +1082,25 @@ void SbiRuntime::PopGosub()
|
|||||||
|
|
||||||
void SbiRuntime::PushArgv()
|
void SbiRuntime::PushArgv()
|
||||||
{
|
{
|
||||||
SbiArgvStack* p = new SbiArgvStack;
|
pArgvStk.emplace_back(refArgv, nArgc);
|
||||||
p->refArgv = refArgv;
|
|
||||||
p->nArgc = nArgc;
|
|
||||||
nArgc = 1;
|
nArgc = 1;
|
||||||
refArgv.Clear();
|
refArgv.Clear();
|
||||||
p->pNext = pArgvStk;
|
|
||||||
pArgvStk = p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SbiRuntime::PopArgv()
|
void SbiRuntime::PopArgv()
|
||||||
{
|
{
|
||||||
if( pArgvStk )
|
if( !pArgvStk.empty() )
|
||||||
{
|
{
|
||||||
SbiArgvStack* p = pArgvStk;
|
refArgv = pArgvStk.back().refArgv;
|
||||||
pArgvStk = p->pNext;
|
nArgc = pArgvStk.back().nArgc;
|
||||||
refArgv = p->refArgv;
|
pArgvStk.pop_back();
|
||||||
nArgc = p->nArgc;
|
|
||||||
delete p;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SbiRuntime::ClearArgvStack()
|
void SbiRuntime::ClearArgvStack()
|
||||||
{
|
{
|
||||||
while( pArgvStk )
|
while( !pArgvStk.empty() )
|
||||||
{
|
{
|
||||||
PopArgv();
|
PopArgv();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user