2010-10-27 13:11:31 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-17 12:30:48 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2013-10-28 03:54:49 +01:00
|
|
|
#ifndef INCLUDED_BASIC_SOURCE_INC_RUNTIME_HXX
|
|
|
|
#define INCLUDED_BASIC_SOURCE_INC_RUNTIME_HXX
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2019-11-08 17:23:15 +01:00
|
|
|
#include <basic/sberrors.hxx>
|
|
|
|
#include <basic/sbmeth.hxx>
|
|
|
|
#include <basic/sbstar.hxx>
|
2007-06-27 13:21:59 +00:00
|
|
|
#include <basic/sbx.hxx>
|
2006-06-19 16:44:06 +00:00
|
|
|
|
|
|
|
#include <rtl/ustring.hxx>
|
2000-09-18 15:18:56 +00:00
|
|
|
#include <com/sun/star/uno/Sequence.hxx>
|
2000-09-26 08:02:02 +00:00
|
|
|
#include <osl/file.hxx>
|
2003-03-18 15:28:40 +00:00
|
|
|
#include <rtl/math.hxx>
|
2013-04-05 18:40:39 +02:00
|
|
|
#include <i18nlangtag/lang.h>
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2001-08-01 10:02:48 +00:00
|
|
|
#include <vector>
|
2015-05-23 14:32:22 +02:00
|
|
|
#include <memory>
|
2001-08-01 10:02:48 +00:00
|
|
|
#include <com/sun/star/lang/XComponent.hpp>
|
2005-01-28 15:07:49 +00:00
|
|
|
#include <com/sun/star/container/XEnumeration.hpp>
|
2006-04-07 13:51:03 +00:00
|
|
|
#include <unotools/localedatawrapper.hxx>
|
2017-11-22 20:46:42 +00:00
|
|
|
#include <o3tl/deleter.hxx>
|
2016-03-06 04:40:30 -08:00
|
|
|
#include <o3tl/typed_flags_set.hxx>
|
2001-08-01 10:02:48 +00:00
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
class SbiInstance; // active StarBASIC process
|
|
|
|
class SbiRuntime; // active StarBASIC procedure instance
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2016-04-04 20:04:24 +02:00
|
|
|
struct SbiArgv; // Argv stack element
|
2016-04-03 16:03:35 +02:00
|
|
|
struct SbiGosub; // GOSUB stack element
|
2000-09-18 15:18:56 +00:00
|
|
|
class SbiImage; // Code-Image
|
2011-08-27 21:37:14 +02:00
|
|
|
class SbiIoSystem;
|
|
|
|
class SbiDdeControl;
|
|
|
|
class SbiDllMgr;
|
|
|
|
class SvNumberFormatter; // time/date functions
|
2015-02-27 11:22:50 +02:00
|
|
|
enum class SbiImageFlags;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2016-03-01 13:14:39 +01:00
|
|
|
enum class ForType {
|
|
|
|
To,
|
|
|
|
EachArray,
|
|
|
|
EachCollection,
|
|
|
|
EachXEnumeration
|
2005-01-28 15:07:49 +00:00
|
|
|
};
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
struct SbiForStack { // for/next stack:
|
2005-01-28 15:07:49 +00:00
|
|
|
SbiForStack* pNext; // Chain
|
|
|
|
SbxVariableRef refVar; // loop variable
|
|
|
|
SbxVariableRef refEnd; // end expression / for each: Array/BasicCollection object
|
|
|
|
SbxVariableRef refInc; // increment expression
|
|
|
|
|
|
|
|
// For each support
|
2016-03-01 13:14:39 +01:00
|
|
|
ForType eForType;
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_Int32 nCurCollectionIndex;
|
2017-07-05 08:57:43 +02:00
|
|
|
std::unique_ptr<sal_Int32[]>
|
|
|
|
pArrayCurIndices;
|
|
|
|
std::unique_ptr<sal_Int32[]>
|
|
|
|
pArrayLowerBounds;
|
|
|
|
std::unique_ptr<sal_Int32[]>
|
|
|
|
pArrayUpperBounds;
|
2013-04-26 17:14:48 +02:00
|
|
|
css::uno::Reference< css::container::XEnumeration > xEnumeration;
|
2005-01-28 15:07:49 +00:00
|
|
|
|
2015-04-14 12:44:47 +02:00
|
|
|
SbiForStack()
|
2015-11-10 10:10:36 +01:00
|
|
|
: pNext(nullptr)
|
2016-03-01 13:14:39 +01:00
|
|
|
, eForType(ForType::To)
|
2014-01-27 13:05:24 +00:00
|
|
|
, nCurCollectionIndex(0)
|
2005-01-28 15:07:49 +00:00
|
|
|
{}
|
2000-09-18 15:18:56 +00:00
|
|
|
};
|
|
|
|
|
2019-09-30 09:49:23 +02:00
|
|
|
#define MAXRECURSION 500 //to prevent dead-recursions
|
2016-03-01 13:14:39 +01:00
|
|
|
|
2016-03-06 04:40:30 -08:00
|
|
|
enum class SbAttributes {
|
|
|
|
NONE = 0x0000,
|
|
|
|
READONLY = 0x0001,
|
|
|
|
HIDDEN = 0x0002,
|
|
|
|
DIRECTORY = 0x0010
|
|
|
|
};
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2016-03-06 04:40:30 -08:00
|
|
|
namespace o3tl
|
|
|
|
{
|
|
|
|
template<> struct typed_flags<SbAttributes> : is_typed_flags<SbAttributes, 0x13> {};
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2005-11-04 14:33:21 +00:00
|
|
|
class WildCard;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
class SbiRTLData
|
|
|
|
{
|
|
|
|
public:
|
2000-09-26 08:02:02 +00:00
|
|
|
|
2016-08-07 12:24:28 +02:00
|
|
|
std::unique_ptr<osl::Directory> pDir;
|
2016-03-06 04:40:30 -08:00
|
|
|
SbAttributes nDirFlags;
|
2000-10-12 13:44:47 +00:00
|
|
|
short nCurDirPos;
|
2000-09-26 08:02:02 +00:00
|
|
|
|
2012-11-06 23:34:23 -06:00
|
|
|
OUString sFullNameToBeChecked;
|
2016-08-07 12:24:28 +02:00
|
|
|
std::unique_ptr<WildCard> pWildCard;
|
2000-11-29 10:32:32 +00:00
|
|
|
|
2013-04-26 17:14:48 +02:00
|
|
|
css::uno::Sequence< OUString > aDirSeq;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
SbiRTLData();
|
|
|
|
~SbiRTLData();
|
|
|
|
};
|
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
// The instance matches a running StarBASIC. Many basics running at the same
|
|
|
|
// time are managed by chained instances. There is all the data that only lives
|
|
|
|
// when the BASIC is living too, like the I/O-system.
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2015-07-20 09:21:24 +02:00
|
|
|
typedef std::vector< css::uno::Reference< css::lang::XComponent > > ComponentVector_t;
|
2001-08-01 10:02:48 +00:00
|
|
|
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
class SbiInstance
|
|
|
|
{
|
|
|
|
friend class SbiRuntime;
|
|
|
|
|
|
|
|
SbiRTLData aRTLData;
|
|
|
|
|
2015-05-23 14:32:22 +02:00
|
|
|
// file system
|
2017-11-22 20:46:42 +00:00
|
|
|
std::unique_ptr<SbiIoSystem, o3tl::default_delete<SbiIoSystem>> pIosys;
|
2015-05-23 14:32:22 +02:00
|
|
|
// DDE
|
|
|
|
std::unique_ptr<SbiDdeControl> pDdeCtrl;
|
|
|
|
// DLL-Calls (DECLARE)
|
|
|
|
std::unique_ptr<SbiDllMgr> pDllMgr;
|
2017-11-24 14:24:03 +01:00
|
|
|
std::shared_ptr<SvNumberFormatter> pNumberFormatter;
|
2000-09-18 15:18:56 +00:00
|
|
|
StarBASIC* pBasic;
|
2001-11-26 15:34:28 +00:00
|
|
|
LanguageType meFormatterLangType;
|
2017-04-13 13:16:27 +02:00
|
|
|
DateOrder meFormatterDateOrder;
|
2005-12-14 13:35:36 +00:00
|
|
|
sal_uInt32 nStdDateIdx, nStdTimeIdx, nStdDateTimeIdx;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-06-14 14:16:48 +02:00
|
|
|
ErrCode nErr;
|
2012-11-06 23:34:23 -06:00
|
|
|
OUString aErrorMsg; // last error message for $ARG
|
|
|
|
sal_Int32 nErl; // current error line
|
2014-04-04 16:52:44 +02:00
|
|
|
bool bReschedule; // Flag: sal_True = Reschedule in main loop
|
|
|
|
bool bCompatibility; // Flag: sal_True = VBA runtime compatibility mode
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2001-08-01 10:02:48 +00:00
|
|
|
ComponentVector_t ComponentVector;
|
2000-09-18 15:18:56 +00:00
|
|
|
public:
|
|
|
|
SbiRuntime* pRun; // Call-Stack
|
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
// #31460 new concept for StepInto/Over/Out,
|
2014-11-10 15:05:25 +01:00
|
|
|
// explanation see runtime.cxx at SbiInstance::CalcBreakCallLevel()
|
2011-08-27 21:37:14 +02:00
|
|
|
sal_uInt16 nCallLvl;
|
|
|
|
sal_uInt16 nBreakCallLvl;
|
2016-11-23 12:31:54 +02:00
|
|
|
void CalcBreakCallLevel( BasicDebugFlags nFlags );
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
SbiInstance( StarBASIC* );
|
|
|
|
~SbiInstance();
|
|
|
|
|
2017-06-14 14:16:48 +02:00
|
|
|
void Error( ErrCode ); // trappable Error
|
|
|
|
void Error( ErrCode, const OUString& rMsg ); // trappable Error with message
|
2012-10-22 21:01:14 +02:00
|
|
|
void ErrorVB( sal_Int32 nVBNumber, const OUString& rMsg );
|
2017-05-08 14:17:56 +02:00
|
|
|
void setErrorVB( sal_Int32 nVBNumber );
|
2017-06-14 14:16:48 +02:00
|
|
|
void FatalError( ErrCode ); // non-trappable Error
|
|
|
|
void FatalError( ErrCode, const OUString& ); // non-trappable Error
|
2011-08-27 21:37:14 +02:00
|
|
|
void Abort(); // with current error code
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
void Stop();
|
2019-09-03 11:47:17 +02:00
|
|
|
ErrCode const & GetErr() const { return nErr; }
|
|
|
|
const OUString& GetErrorMsg() const { return aErrorMsg; }
|
|
|
|
sal_Int32 GetErl() const { return nErl; }
|
2014-04-04 16:52:44 +02:00
|
|
|
void EnableReschedule( bool bEnable ) { bReschedule = bEnable; }
|
2019-09-03 11:47:17 +02:00
|
|
|
bool IsReschedule() const { return bReschedule; }
|
2014-04-04 16:52:44 +02:00
|
|
|
void EnableCompatibility( bool bEnable ) { bCompatibility = bEnable; }
|
2019-09-03 11:47:17 +02:00
|
|
|
bool IsCompatibility() const { return bCompatibility; }
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2015-04-14 12:44:47 +02:00
|
|
|
ComponentVector_t& getComponentVector() { return ComponentVector; }
|
2001-08-01 10:02:48 +00:00
|
|
|
|
2011-01-10 14:40:57 +01:00
|
|
|
SbMethod* GetCaller( sal_uInt16 );
|
2000-09-18 15:18:56 +00:00
|
|
|
SbModule* GetActiveModule();
|
|
|
|
|
2015-05-23 14:32:22 +02:00
|
|
|
SbiIoSystem* GetIoSystem() { return pIosys.get(); }
|
|
|
|
SbiDdeControl* GetDdeControl() { return pDdeCtrl.get(); }
|
2015-04-14 12:44:47 +02:00
|
|
|
StarBASIC* GetBasic() { return pBasic; }
|
2000-09-18 15:18:56 +00:00
|
|
|
SbiDllMgr* GetDllMgr();
|
2018-11-04 19:24:22 +03:00
|
|
|
SbiRTLData& GetRTLData() const { return const_cast<SbiRTLData&>(aRTLData); }
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-12-26 08:32:51 +02:00
|
|
|
std::shared_ptr<SvNumberFormatter> const & GetNumberFormatter();
|
2005-12-14 13:35:36 +00:00
|
|
|
sal_uInt32 GetStdDateIdx() const { return nStdDateIdx; }
|
|
|
|
sal_uInt32 GetStdTimeIdx() const { return nStdTimeIdx; }
|
|
|
|
sal_uInt32 GetStdDateTimeIdx() const { return nStdDateTimeIdx; }
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
// offer NumberFormatter also static
|
2017-11-24 14:24:03 +01:00
|
|
|
static std::shared_ptr<SvNumberFormatter> PrepareNumberFormatter( sal_uInt32 &rnStdDateIdx,
|
2015-05-23 14:32:22 +02:00
|
|
|
sal_uInt32 &rnStdTimeIdx, sal_uInt32 &rnStdDateTimeIdx,
|
2017-11-02 12:09:52 +02:00
|
|
|
LanguageType const * peFormatterLangType=nullptr, DateOrder const * peFormatterDateOrder=nullptr );
|
2000-09-18 15:18:56 +00:00
|
|
|
};
|
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
// 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.
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
class SbiRuntime
|
|
|
|
{
|
2014-04-04 16:52:44 +02:00
|
|
|
friend void SbRtl_CallByName( StarBASIC* pBasic, SbxArray& rPar, bool bWrite );
|
2010-08-19 14:22:48 +02:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
typedef void( SbiRuntime::*pStep0 )();
|
2011-01-10 14:40:57 +01:00
|
|
|
typedef void( SbiRuntime::*pStep1 )( sal_uInt32 nOp1 );
|
|
|
|
typedef void( SbiRuntime::*pStep2 )( sal_uInt32 nOp1, sal_uInt32 nOp2 );
|
2011-08-27 21:37:14 +02:00
|
|
|
static pStep0 aStep0[]; // opcode-table group 0
|
|
|
|
static pStep1 aStep1[];
|
|
|
|
static pStep2 aStep2[];
|
|
|
|
|
2016-11-23 12:31:54 +02:00
|
|
|
StarBASIC& rBasic; // StarBASIC instance
|
|
|
|
SbiInstance* pInst; // current thread
|
|
|
|
SbModule* pMod; // current module
|
|
|
|
SbMethod* pMeth; // method instance
|
|
|
|
SbiIoSystem* pIosys; // I/O-System
|
|
|
|
const SbiImage* pImg; // Code-Image
|
|
|
|
SbxArrayRef refExprStk; // expression stack
|
|
|
|
SbxArrayRef refCaseStk; // CASE expression stack
|
|
|
|
SbxArrayRef refRedimpArray; // Array saved to use for REDIM PRESERVE
|
|
|
|
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 )
|
|
|
|
SbiForStack* pForStk; // FOR/NEXT-Stack
|
|
|
|
sal_uInt16 nExprLvl; // depth of the expr-stack
|
|
|
|
sal_uInt16 nForLvl; // #118235: Maintain for level
|
2011-08-27 21:37:14 +02:00
|
|
|
const sal_uInt8* pCode; // current Code-Pointer
|
|
|
|
const sal_uInt8* pStmnt; // beginning of the last statement
|
|
|
|
const sal_uInt8* pError; // address of the current error handler
|
|
|
|
const sal_uInt8* pRestart; // restart-address
|
2018-09-06 18:28:52 +02:00
|
|
|
const sal_uInt8* pErrCode; // restart-address RESUME NEXT
|
|
|
|
const sal_uInt8* pErrStmnt; // restart-address RESUME 0
|
2016-11-23 12:31:54 +02:00
|
|
|
OUString aLibName; // Lib-name for declare-call
|
|
|
|
SbxArrayRef refParams; // current procedure parameters
|
|
|
|
SbxArrayRef refLocals; // local variable
|
|
|
|
SbxArrayRef refArgv;
|
2011-08-27 21:37:14 +02:00
|
|
|
// #74254, one refSaveObj is not enough! new: pRefSaveList (see above)
|
2016-11-23 12:31:54 +02:00
|
|
|
short nArgc;
|
|
|
|
bool bRun;
|
|
|
|
bool bError; // true: handle errors
|
|
|
|
bool bInError; // true: in an error handler
|
|
|
|
bool bBlocked; // true: blocked by next call level, #i48868
|
|
|
|
bool bVBAEnabled;
|
|
|
|
BasicDebugFlags nFlags; // Debugging-Flags
|
2017-06-14 14:16:48 +02:00
|
|
|
ErrCode nError;
|
2016-11-23 12:31:54 +02:00
|
|
|
sal_uInt16 nOps; // opcode counter
|
|
|
|
sal_uInt32 m_nLastTime;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2016-03-13 18:25:00 +01:00
|
|
|
std::vector<SbxVariableRef> aRefSaved; // #74254 save temporary references
|
2016-11-23 12:31:54 +02:00
|
|
|
std::vector<SbiGosub> pGosubStk; // GOSUB stack
|
|
|
|
std::vector<SbiArgv> pArgvStk; // ARGV-Stack
|
2016-04-03 16:03:35 +02:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
SbxVariable* FindElement
|
2017-06-14 14:16:48 +02:00
|
|
|
( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt32 nOp2, ErrCode, bool bLocal, bool bStatic = false );
|
2011-01-10 14:40:57 +01:00
|
|
|
void SetupArgs( SbxVariable*, sal_uInt32 );
|
2000-09-18 15:18:56 +00:00
|
|
|
SbxVariable* CheckArray( SbxVariable* );
|
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
void PushVar( SbxVariable* );
|
|
|
|
SbxVariableRef PopVar();
|
2016-03-02 16:44:45 +02:00
|
|
|
SbxVariable* GetTOS();
|
2011-08-27 21:37:14 +02:00
|
|
|
void TOSMakeTemp();
|
2015-08-16 12:18:36 +02:00
|
|
|
void ClearExprStack();
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
void PushGosub( const sal_uInt8* );
|
|
|
|
void PopGosub();
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
void PushArgv();
|
|
|
|
void PopArgv();
|
|
|
|
void ClearArgvStack();
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
void PushFor();
|
|
|
|
void PushForEach();
|
|
|
|
void PopFor();
|
|
|
|
void ClearForStack();
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
void StepArith( SbxOperator );
|
|
|
|
void StepUnary( SbxOperator );
|
|
|
|
void StepCompare( SbxOperator );
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
void SetParameters( SbxArray* );
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
// HAS TO BE IMPLEMENTED SOME TIME
|
2012-11-06 23:34:23 -06:00
|
|
|
void DllCall( const OUString&, const OUString&, SbxArray*, SbxDataType, bool );
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
// #56204 swap out DIM-functionality into help method (step0.cxx)
|
2018-09-06 08:50:58 +02:00
|
|
|
void DimImpl(const SbxVariableRef& refVar);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-07-20 10:08:03 +02:00
|
|
|
static bool implIsClass( SbxObject const * pObj, const OUString& aClass );
|
2005-03-29 10:51:12 +00:00
|
|
|
|
2016-08-02 14:56:27 +02:00
|
|
|
void StepSETCLASS_impl( sal_uInt32 nOp1, bool bHandleDflt );
|
2007-08-30 09:01:05 +00:00
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
// the following routines are called by the single
|
|
|
|
// stepper and implement the single opcodes
|
2000-09-18 15:18:56 +00:00
|
|
|
void StepNOP(), StepEXP(), StepMUL(), StepDIV();
|
|
|
|
void StepMOD(), StepPLUS(), StepMINUS(), StepNEG();
|
|
|
|
void StepEQ(), StepNE(), StepLT(), StepGT();
|
|
|
|
void StepLE(), StepGE(), StepIDIV(), StepAND();
|
|
|
|
void StepOR(), StepXOR(), StepEQV(), StepIMP();
|
|
|
|
void StepNOT(), StepCAT(), StepLIKE(), StepIS();
|
2015-07-14 14:50:07 +02:00
|
|
|
void StepARGC();
|
2000-09-18 15:18:56 +00:00
|
|
|
void StepARGV(), StepINPUT(), StepLINPUT(), StepSTOP();
|
2006-11-02 15:32:35 +00:00
|
|
|
void StepGET(), StepSET(), StepVBASET(), StepPUT(), StepPUTC();
|
|
|
|
void StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, bool bDefaultHandling = false );
|
2000-09-18 15:18:56 +00:00
|
|
|
void StepDIM(), StepREDIM(), StepREDIMP(), StepERASE();
|
2005-01-28 15:07:49 +00:00
|
|
|
void StepINITFOR(), StepNEXT(), StepERROR(), StepINITFOREACH();
|
2000-09-18 15:18:56 +00:00
|
|
|
void StepCASE(), StepENDCASE(), StepSTDERROR();
|
|
|
|
void StepNOERROR(), StepCHANNEL(), StepCHANNEL0(), StepPRINT();
|
|
|
|
void StepPRINTF(), StepWRITE(), StepRENAME(), StepPROMPT();
|
|
|
|
void StepRESTART(), StepEMPTY(), StepLEAVE();
|
2007-08-30 09:01:05 +00:00
|
|
|
void StepLSET(), StepRSET(), StepREDIMP_ERASE(), StepERASE_CLEAR();
|
2010-06-15 20:02:53 +02:00
|
|
|
void StepARRAYACCESS(), StepBYVAL();
|
2011-08-27 21:37:14 +02:00
|
|
|
// all opcodes with one operand
|
2011-01-10 14:40:57 +01:00
|
|
|
void StepLOADNC( sal_uInt32 ), StepLOADSC( sal_uInt32 ), StepLOADI( sal_uInt32 );
|
|
|
|
void StepARGN( sal_uInt32 ), StepBASED( sal_uInt32 ), StepPAD( sal_uInt32 );
|
|
|
|
void StepJUMP( sal_uInt32 ), StepJUMPT( sal_uInt32 );
|
|
|
|
void StepJUMPF( sal_uInt32 ), StepONJUMP( sal_uInt32 );
|
|
|
|
void StepGOSUB( sal_uInt32 ), StepRETURN( sal_uInt32 );
|
|
|
|
void StepTESTFOR( sal_uInt32 ), StepCASETO( sal_uInt32 ), StepERRHDL( sal_uInt32 );
|
|
|
|
void StepRESUME( sal_uInt32 ), StepSETCLASS( sal_uInt32 ), StepVBASETCLASS( sal_uInt32 ), StepTESTCLASS( sal_uInt32 ), StepLIB( sal_uInt32 );
|
2016-08-02 14:56:27 +02:00
|
|
|
bool checkClass_Impl( const SbxVariableRef& refVal, const OUString& aClass, bool bRaiseErrors, bool bDefault );
|
2011-01-10 14:40:57 +01:00
|
|
|
void StepCLOSE( sal_uInt32 ), StepPRCHAR( sal_uInt32 ), StepARGTYP( sal_uInt32 );
|
2011-08-27 21:37:14 +02:00
|
|
|
// all opcodes with two operands
|
2011-01-10 14:40:57 +01:00
|
|
|
void StepRTL( sal_uInt32, sal_uInt32 ), StepPUBLIC( sal_uInt32, sal_uInt32 ), StepPUBLIC_P( sal_uInt32, sal_uInt32 );
|
|
|
|
void StepPUBLIC_Impl( sal_uInt32, sal_uInt32, bool bUsedForClassModule );
|
2017-06-14 14:16:48 +02:00
|
|
|
void StepFIND_Impl( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt32 nOp2, ErrCode, bool bStatic = false );
|
2011-01-10 14:40:57 +01:00
|
|
|
void StepFIND( sal_uInt32, sal_uInt32 ), StepELEM( sal_uInt32, sal_uInt32 );
|
|
|
|
void StepGLOBAL( sal_uInt32, sal_uInt32 ), StepLOCAL( sal_uInt32, sal_uInt32 );
|
|
|
|
void StepPARAM( sal_uInt32, sal_uInt32), StepCREATE( sal_uInt32, sal_uInt32 );
|
|
|
|
void StepCALL( sal_uInt32, sal_uInt32 ), StepCALLC( sal_uInt32, sal_uInt32 );
|
|
|
|
void StepCASEIS( sal_uInt32, sal_uInt32 ), StepSTMNT( sal_uInt32, sal_uInt32 );
|
Call implHandleSbxFlags also from StepSTATIC_Impl
...similarly to how it is called from StepLOCAL and StepPUBLIC_Impl.
Now that there's basic/qa/vba_tests/mirr.vb containing
Static Values(5) As Double ' Set up array.
that caused CppunitTest_basic_macros to fail in UBSan builds with
> /basic/source/runtime/runtime.cxx:4613:34: runtime error: load of value 262149, which is not a valid value for type 'SbxDataType'
> #0 0x2b25aa72d3f5 in SbiRuntime::StepSTATIC_Impl(rtl::OUString&, SbxDataType&) /basic/source/runtime/runtime.cxx:4613:34
> #1 0x2b25aa6e821f in SbiRuntime::StepSTATIC(unsigned int, unsigned int) /basic/source/runtime/runtime.cxx:4629:5
> #2 0x2b25aa6ff0cf in SbiRuntime::Step() /basic/source/runtime/runtime.cxx:770:13
> #3 0x2b25aa237cba in SbModule::Run(SbMethod*) /basic/source/classes/sbxmod.cxx:1144:20
> #4 0x2b25aa232916 in SbModule::Notify(SfxBroadcaster&, SfxHint const&) /basic/source/classes/sbxmod.cxx:809:21
> #5 0x2b259b0f51f1 in SfxBroadcaster::Broadcast(SfxHint const&) /svl/source/notify/SfxBroadcaster.cxx:49:13
> #6 0x2b25aa267165 in SbMethod::Broadcast(SfxHintId) /basic/source/classes/sbxmod.cxx:2126:9
> #7 0x2b25aaa96fb9 in SbxValue::SbxValue(SbxValue const&) /basic/source/sbx/sbxvalue.cxx:62:9
> #8 0x2b25aaae16ec in SbxVariable::SbxVariable(SbxVariable const&) /basic/source/sbx/sbxvar.cxx:73:7
> #9 0x2b25aaa51afd in SbxMethod::SbxMethod(SbxMethod const&) /basic/source/sbx/sbxobj.cxx:869:7
> #10 0x2b25aa72c12b in SbiRuntime::FindElement(SbxObject*, unsigned int, unsigned int, unsigned long, bool, bool) /basic/source/runtime/runtime.cxx:3518:37
> #11 0x2b25aa735314 in SbiRuntime::StepFIND_Impl(SbxObject*, unsigned int, unsigned int, unsigned long, bool) /basic/source/runtime/runtime.cxx:3941:14
> #12 0x2b25aa6da643 in SbiRuntime::StepFIND(unsigned int, unsigned int) /basic/source/runtime/runtime.cxx:3947:5
> #13 0x2b25aa6ff0cf in SbiRuntime::Step() /basic/source/runtime/runtime.cxx:770:13
> #14 0x2b25aa237cba in SbModule::Run(SbMethod*) /basic/source/classes/sbxmod.cxx:1144:20
> #15 0x2b25aa232916 in SbModule::Notify(SfxBroadcaster&, SfxHint const&) /basic/source/classes/sbxmod.cxx:809:21
> #16 0x2b259b0f51f1 in SfxBroadcaster::Broadcast(SfxHint const&) /svl/source/notify/SfxBroadcaster.cxx:49:13
> #17 0x2b25aa267165 in SbMethod::Broadcast(SfxHintId) /basic/source/classes/sbxmod.cxx:2126:9
> #18 0x2b25aaa96fb9 in SbxValue::SbxValue(SbxValue const&) /basic/source/sbx/sbxvalue.cxx:62:9
> #19 0x2b25aaae16ec in SbxVariable::SbxVariable(SbxVariable const&) /basic/source/sbx/sbxvar.cxx:73:7
> #20 0x2b25aaa51afd in SbxMethod::SbxMethod(SbxMethod const&) /basic/source/sbx/sbxobj.cxx:869:7
> #21 0x2b25a9010a4a in MacroSnippet::Run(com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&) /basic/qa/cppunit/basictest.cxx:95:23
> #22 0x2b25a9012797 in MacroSnippet::Run() /basic/qa/cppunit/basictest.cxx:103:12
> #23 0x2b25a908e336 in (anonymous namespace)::VBATest::testMiscVBAFunctions() /basic/qa/cppunit/test_vba.cxx:125:34
> #24 0x2b25a90964a8 in void std::_Mem_fn_base<void ((anonymous namespace)::VBATest::*)(), true>::operator()<, void>((anonymous namespace)::VBATest*) const /home/tdf/lode/opt_private/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../include/c++/5.2.0/functional:600:11
> #25 0x2b25a90961d3 in void std::_Bind<std::_Mem_fn<void ((anonymous namespace)::VBATest::*)()> ((anonymous namespace)::VBATest*)>::__call<void, , 0ul>(std::tuple<>&&, std::_Index_tuple<0ul>) /home/tdf/lode/opt_private/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../include/c++/5.2.0/functional:1073:11
> #26 0x2b25a9095c81 in void std::_Bind<std::_Mem_fn<void ((anonymous namespace)::VBATest::*)()> ((anonymous namespace)::VBATest*)>::operator()<, void>() /home/tdf/lode/opt_private/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../include/c++/5.2.0/functional:1131:11
> #27 0x2b25a9094a79 in std::_Function_handler<void (), std::_Bind<std::_Mem_fn<void ((anonymous namespace)::VBATest::*)()> ((anonymous namespace)::VBATest*)> >::_M_invoke(std::_Any_data const&) /home/tdf/lode/opt_private/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../include/c++/5.2.0/functional:1871:2
> #28 0x2b25a9046710 in std::function<void ()>::operator()() const /home/tdf/lode/opt_private/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../include/c++/5.2.0/functional:2271:14
> #29 0x2b25a9093175 in CppUnit::TestCaller<(anonymous namespace)::VBATest>::runTest() /workdir/UnpackedTarball/cppunit/include/cppunit/TestCaller.h:175:7
> #30 0x2b256430d0ad in CppUnit::TestCaseMethodFunctor::operator()() const /workdir/UnpackedTarball/cppunit/src/cppunit/TestCase.cpp:32:5
> #31 0x2b257d507ea6 in (anonymous namespace)::Protector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) /test/source/vclbootstrapprotector.cxx:39:14
> #32 0x2b25642cbb77 in CppUnit::ProtectorChain::ProtectFunctor::operator()() const /workdir/UnpackedTarball/cppunit/src/cppunit/ProtectorChain.cpp:20:12
> #33 0x2b2573b757f6 in (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) /unotest/source/cpp/unobootstrapprotector/unobootstrapprotector.cxx:89:12
> #34 0x2b25642cbb77 in CppUnit::ProtectorChain::ProtectFunctor::operator()() const /workdir/UnpackedTarball/cppunit/src/cppunit/ProtectorChain.cpp:20:12
> #35 0x2b256fd37d83 in (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) /unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx:63:16
> #36 0x2b25642cbb77 in CppUnit::ProtectorChain::ProtectFunctor::operator()() const /workdir/UnpackedTarball/cppunit/src/cppunit/ProtectorChain.cpp:20:12
> #37 0x2b256424750f in CppUnit::DefaultProtector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) /workdir/UnpackedTarball/cppunit/src/cppunit/DefaultProtector.cpp:15:12
> #38 0x2b25642cbb77 in CppUnit::ProtectorChain::ProtectFunctor::operator()() const /workdir/UnpackedTarball/cppunit/src/cppunit/ProtectorChain.cpp:20:12
> #39 0x2b25642c1da0 in CppUnit::ProtectorChain::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) /workdir/UnpackedTarball/cppunit/src/cppunit/ProtectorChain.cpp:86:18
> #40 0x2b2564396efb in CppUnit::TestResult::protect(CppUnit::Functor const&, CppUnit::Test*, std::string const&) /workdir/UnpackedTarball/cppunit/src/cppunit/TestResult.cpp:182:10
> #41 0x2b256430a12d in CppUnit::TestCase::run(CppUnit::TestResult*) /workdir/UnpackedTarball/cppunit/src/cppunit/TestCase.cpp:91:5
> #42 0x2b25643102e3 in CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) /workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:64:5
> #43 0x2b256430f24d in CppUnit::TestComposite::run(CppUnit::TestResult*) /workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:23:3
> #44 0x2b25643102e3 in CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) /workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:64:5
> #45 0x2b256430f24d in CppUnit::TestComposite::run(CppUnit::TestResult*) /workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:23:3
> #46 0x2b25643d68b6 in CppUnit::TestRunner::WrappingSuite::run(CppUnit::TestResult*) /workdir/UnpackedTarball/cppunit/src/cppunit/TestRunner.cpp:47:5
> #47 0x2b2564395049 in CppUnit::TestResult::runTest(CppUnit::Test*) /workdir/UnpackedTarball/cppunit/src/cppunit/TestResult.cpp:149:3
> #48 0x2b25643d7d57 in CppUnit::TestRunner::run(CppUnit::TestResult&, std::string const&) /workdir/UnpackedTarball/cppunit/src/cppunit/TestRunner.cpp:96:3
> #49 0x5161f2 in (anonymous namespace)::ProtectedFixtureFunctor::run() const /sal/cppunittester/cppunittester.cxx:306:13
> #50 0x510c8f in sal_main() /sal/cppunittester/cppunittester.cxx:456:14
> #51 0x50eda2 in main /sal/cppunittester/cppunittester.cxx:363:1
> #52 0x2b2565ff6b14 in __libc_start_main (/lib64/libc.so.6+0x21b14)
> #53 0x433a04 in _start (/workdir/LinkTarget/Executable/cppunittester+0x433a04)
(where 262149 = 0x40005, i.e., SbxDOUBLE|SBX_TYPE_VAR_TO_DIM_FLAG)
Change-Id: Ib35a5c66c9b3266c13616f4cb896d533378a8eb0
2017-04-18 17:01:30 +02:00
|
|
|
SbxVariable* StepSTATIC_Impl(
|
2017-04-18 17:23:05 +02:00
|
|
|
OUString const & aName, SbxDataType t, sal_uInt32 nOp2 );
|
2011-01-10 14:40:57 +01:00
|
|
|
void StepOPEN( sal_uInt32, sal_uInt32 ), StepSTATIC( sal_uInt32, sal_uInt32 );
|
|
|
|
void StepTCREATE(sal_uInt32,sal_uInt32), StepDCREATE(sal_uInt32,sal_uInt32);
|
|
|
|
void StepGLOBAL_P( sal_uInt32, sal_uInt32 ),StepFIND_G( sal_uInt32, sal_uInt32 );
|
|
|
|
void StepDCREATE_REDIMP(sal_uInt32,sal_uInt32), StepDCREATE_IMPL(sal_uInt32,sal_uInt32);
|
|
|
|
void StepFIND_CM( sal_uInt32, sal_uInt32 );
|
|
|
|
void StepFIND_STATIC( sal_uInt32, sal_uInt32 );
|
2015-04-10 11:07:36 +02:00
|
|
|
static void implHandleSbxFlags( SbxVariable* pVar, SbxDataType t, sal_uInt32 nOp2 );
|
2000-09-18 15:18:56 +00:00
|
|
|
public:
|
2010-03-02 12:39:31 +00:00
|
|
|
void SetVBAEnabled( bool bEnabled );
|
2015-02-27 11:22:50 +02:00
|
|
|
bool IsImageFlag( SbiImageFlags n ) const;
|
2019-09-03 11:47:17 +02:00
|
|
|
sal_uInt16 GetBase() const;
|
2012-11-06 23:34:23 -06:00
|
|
|
sal_Int32 nLine,nCol1,nCol2;
|
2000-09-18 15:18:56 +00:00
|
|
|
SbiRuntime* pNext; // Stack-Chain
|
|
|
|
|
2020-03-09 11:53:50 +01:00
|
|
|
// tdf#79426, tdf#125180 - adds the information about a missing parameter
|
|
|
|
static void SetIsMissing( SbxVariable* );
|
|
|
|
// tdf#79426, tdf#125180 - checks if a variable contains the information about a missing parameter
|
|
|
|
static bool IsMissing( SbxVariable*, sal_uInt16 );
|
|
|
|
|
2011-01-10 14:40:57 +01:00
|
|
|
SbiRuntime( SbModule*, SbMethod*, sal_uInt32 );
|
2000-09-18 15:18:56 +00:00
|
|
|
~SbiRuntime();
|
2017-06-14 14:16:48 +02:00
|
|
|
void Error( ErrCode, bool bVBATranslationAlreadyDone = false ); // set error if != 0
|
|
|
|
void Error( ErrCode, const OUString& ); // set error if != 0
|
|
|
|
void FatalError( ErrCode ); // error handling = standard, set error
|
|
|
|
void FatalError( ErrCode, const OUString& ); // error handling = standard, set error
|
|
|
|
static sal_Int32 translateErrorToVba( ErrCode nError, OUString& rMsg );
|
2012-08-21 22:54:26 +09:00
|
|
|
bool Step(); // single step (one opcode)
|
|
|
|
void Stop() { bRun = false; }
|
2015-04-14 12:44:47 +02:00
|
|
|
void block() { bBlocked = true; }
|
|
|
|
void unblock() { bBlocked = false; }
|
2000-09-18 15:18:56 +00:00
|
|
|
SbModule* GetModule() { return pMod; }
|
2019-09-03 11:47:17 +02:00
|
|
|
BasicDebugFlags GetDebugFlags() const { return nFlags; }
|
2016-11-23 12:31:54 +02:00
|
|
|
void SetDebugFlags( BasicDebugFlags nFl ) { nFlags = nFl; }
|
2014-06-09 10:09:42 +02:00
|
|
|
SbMethod* GetCaller() { return pMeth;}
|
2010-10-06 10:16:27 +01:00
|
|
|
SbxVariable* GetExternalCaller(){ return mpExtCaller; }
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-07-20 10:08:03 +02:00
|
|
|
SbiForStack* FindForStackItemForCollection( class BasicCollection const * pCollection );
|
2011-03-25 10:40:25 +01:00
|
|
|
|
2012-10-26 09:26:36 +02:00
|
|
|
SbxBase* FindElementExtern( const OUString& rName );
|
2006-05-05 09:12:35 +00:00
|
|
|
static bool isVBAEnabled();
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
};
|
|
|
|
|
2001-08-22 09:43:13 +00:00
|
|
|
inline void checkArithmeticOverflow( double d )
|
|
|
|
{
|
2020-03-09 23:22:20 +09:00
|
|
|
if( !std::isfinite( d ) )
|
2015-07-27 13:04:00 +02:00
|
|
|
StarBASIC::Error( ERRCODE_BASIC_MATH_OVERFLOW );
|
2001-08-22 09:43:13 +00:00
|
|
|
}
|
|
|
|
|
2017-07-20 10:08:03 +02:00
|
|
|
inline void checkArithmeticOverflow( SbxVariable const * pVar )
|
2001-08-22 09:43:13 +00:00
|
|
|
{
|
|
|
|
if( pVar->GetType() == SbxDOUBLE )
|
|
|
|
{
|
|
|
|
double d = pVar->GetDouble();
|
|
|
|
checkArithmeticOverflow( d );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
StarBASIC* GetCurrentBasic( StarBASIC* pRTBasic );
|
|
|
|
|
2012-08-21 22:54:26 +09:00
|
|
|
// Returns true if UNO is available, otherwise the old
|
2000-09-18 15:18:56 +00:00
|
|
|
// file system implementation has to be used
|
|
|
|
// (Implemented in iosys.cxx)
|
2015-04-14 12:44:47 +02:00
|
|
|
bool hasUno();
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// Converts possibly relative paths to absolute paths
|
|
|
|
// according to the setting done by ChDir/ChDrive
|
|
|
|
// (Implemented in methods.cxx)
|
2012-11-06 23:34:23 -06:00
|
|
|
OUString getFullPath( const OUString& aRelPath );
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// Implementation of StepRENAME with UCB
|
|
|
|
// (Implemented in methods.cxx, so step0.cxx
|
|
|
|
// has not to be infected with UNO)
|
2012-11-06 23:34:23 -06:00
|
|
|
void implStepRenameUCB( const OUString& aSource, const OUString& aDest );
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2012-11-06 23:34:23 -06:00
|
|
|
void implStepRenameOSL( const OUString& aSource, const OUString& aDest );
|
2008-07-02 09:00:35 +00:00
|
|
|
bool IsBaseIndexOne();
|
2000-09-26 08:02:02 +00:00
|
|
|
|
2014-04-09 10:11:46 +02:00
|
|
|
void removeDimAsNewRecoverItem( SbxVariable* pVar );
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
#endif
|
2008-06-24 15:03:35 +00:00
|
|
|
|
2010-10-27 13:11:31 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|