diff options
author | Arnaud Versini <arnaud.versini@gmail.com> | 2016-04-04 20:04:24 +0200 |
---|---|---|
committer | Arnaud Versini <arnaud.versini@libreoffice.org> | 2016-04-04 19:44:19 +0000 |
commit | c1e4d402c61cc33a67d32b037bda027dadb0964a (patch) | |
tree | 8c57b3f42bf2d1f82af945cfe4eb203edc698d18 /basic/source | |
parent | 82a04a82699a87daa67c162896d6f7e2c1bbfe26 (diff) |
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>
Diffstat (limited to 'basic/source')
-rw-r--r-- | basic/source/inc/runtime.hxx | 4 | ||||
-rw-r--r-- | basic/source/runtime/runtime.cxx | 26 |
2 files changed, 13 insertions, 17 deletions
diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx index 6d1a8a01f577..50dbb5b1170e 100644 --- a/basic/source/inc/runtime.hxx +++ b/basic/source/inc/runtime.hxx @@ -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 diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 80815fe279e9..76a763391dbc 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -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(); } |