xref: /AOO41X/main/basic/source/inc/runtime.hxx (revision 234bd5c559aaf7abbd02d045859137b774cd8b34)
1*234bd5c5SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*234bd5c5SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*234bd5c5SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*234bd5c5SAndrew Rist  * distributed with this work for additional information
6*234bd5c5SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*234bd5c5SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*234bd5c5SAndrew Rist  * "License"); you may not use this file except in compliance
9*234bd5c5SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*234bd5c5SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*234bd5c5SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*234bd5c5SAndrew Rist  * software distributed under the License is distributed on an
15*234bd5c5SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*234bd5c5SAndrew Rist  * KIND, either express or implied.  See the License for the
17*234bd5c5SAndrew Rist  * specific language governing permissions and limitations
18*234bd5c5SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*234bd5c5SAndrew Rist  *************************************************************/
21*234bd5c5SAndrew Rist 
22*234bd5c5SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SBRUNTIME_HXX
25cdf0e10cSrcweir #define _SBRUNTIME_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _SBX_HXX
28cdf0e10cSrcweir #include <basic/sbx.hxx>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "sb.hxx"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir // Define activates class UCBStream in iosys.cxx
34cdf0e10cSrcweir #define _USE_UNO
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #ifdef _USE_UNO
37cdf0e10cSrcweir #include <rtl/ustring.hxx>
38cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
39cdf0e10cSrcweir #include <osl/file.hxx>
40cdf0e10cSrcweir #include <rtl/math.hxx>
41cdf0e10cSrcweir #include <i18npool/lang.h>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <vector>
44cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
45cdf0e10cSrcweir #include <com/sun/star/container/XEnumeration.hpp>
46cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir using namespace com::sun::star::uno;
49cdf0e10cSrcweir using namespace com::sun::star::lang;
50cdf0e10cSrcweir using namespace com::sun::star::container;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 
53cdf0e10cSrcweir // Define activates old file implementation
54cdf0e10cSrcweir // (only in non UCB case)
55cdf0e10cSrcweir // #define _OLD_FILE_IMPL
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 
58cdf0e10cSrcweir //#include <sal/types.h>
59cdf0e10cSrcweir //#include <rtl/byteseq.hxx>
60cdf0e10cSrcweir //#include <rtl/ustring>
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 
63cdf0e10cSrcweir namespace basicEncoder
64cdf0e10cSrcweir {
65cdf0e10cSrcweir 
66cdf0e10cSrcweir // TODO: Use exported functionality (code is copied from deamons2/ucb)
67cdf0e10cSrcweir class AsciiEncoder
68cdf0e10cSrcweir {
69cdf0e10cSrcweir public:
70cdf0e10cSrcweir 	static ::rtl::OUString decodeUnoUrlParamValue(const rtl::OUString & rSource);
71cdf0e10cSrcweir 	//static ::rtl::OUString encodeUnoUrlParamValue(const rtl::OUString & rSource);
72cdf0e10cSrcweir 	//static ::rtl::ByteSequence decode(const ::rtl::OUString & string);
73cdf0e10cSrcweir 	//static ::rtl::OUString encode(const ::rtl::ByteSequence & bytes);
74cdf0e10cSrcweir 	//static void test();
75cdf0e10cSrcweir };
76cdf0e10cSrcweir 
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir #endif /* _USE_UNO */
80cdf0e10cSrcweir 
81cdf0e10cSrcweir class SbiInstance;					// aktiver StarBASIC-Prozess
82cdf0e10cSrcweir class SbiRuntime;					// aktive StarBASIC-Prozedur-Instanz
83cdf0e10cSrcweir 
84cdf0e10cSrcweir struct SbiArgvStack;                // Argv stack element
85cdf0e10cSrcweir struct SbiGosubStack;               // GOSUB stack element
86cdf0e10cSrcweir class  SbiImage;                    // Code-Image
87cdf0e10cSrcweir class  SbiIoSystem;                 // Dateisystem
88cdf0e10cSrcweir class  SbiDdeControl;				// DDE-Steuerung
89cdf0e10cSrcweir class  SbiDllMgr;					// Aufrufe in DLLs
90cdf0e10cSrcweir class  SvNumberFormatter;			// Zeit/Datumsfunktionen
91cdf0e10cSrcweir 
92cdf0e10cSrcweir enum ForType
93cdf0e10cSrcweir {
94cdf0e10cSrcweir 	FOR_TO,
95cdf0e10cSrcweir 	FOR_EACH_ARRAY,
96cdf0e10cSrcweir 	FOR_EACH_COLLECTION,
97cdf0e10cSrcweir 	FOR_EACH_XENUMERATION
98cdf0e10cSrcweir };
99cdf0e10cSrcweir 
100cdf0e10cSrcweir struct SbiForStack { 		  		// for/next stack:
101cdf0e10cSrcweir 	SbiForStack*	pNext;	   		// Chain
102cdf0e10cSrcweir 	SbxVariableRef	refVar;	   		// loop variable
103cdf0e10cSrcweir 	SbxVariableRef	refEnd;	   		// end expression / for each: Array/BasicCollection object
104cdf0e10cSrcweir 	SbxVariableRef	refInc;	   		// increment expression
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	// For each support
107cdf0e10cSrcweir 	ForType			eForType;
108cdf0e10cSrcweir 	sal_Int32			nCurCollectionIndex;
109cdf0e10cSrcweir 	sal_Int32*			pArrayCurIndices;
110cdf0e10cSrcweir 	sal_Int32*			pArrayLowerBounds;
111cdf0e10cSrcweir 	sal_Int32*			pArrayUpperBounds;
112cdf0e10cSrcweir 	Reference< XEnumeration > xEnumeration;
113cdf0e10cSrcweir 
SbiForStackSbiForStack114cdf0e10cSrcweir 	SbiForStack( void )
115cdf0e10cSrcweir 		: pArrayCurIndices( NULL )
116cdf0e10cSrcweir 		, pArrayLowerBounds( NULL )
117cdf0e10cSrcweir 		, pArrayUpperBounds( NULL )
118cdf0e10cSrcweir 	{}
~SbiForStackSbiForStack119cdf0e10cSrcweir 	~SbiForStack()
120cdf0e10cSrcweir 	{
121cdf0e10cSrcweir 		delete[] pArrayCurIndices;
122cdf0e10cSrcweir 		delete[] pArrayLowerBounds;
123cdf0e10cSrcweir 		delete[] pArrayUpperBounds;
124cdf0e10cSrcweir 	}
125cdf0e10cSrcweir };
126cdf0e10cSrcweir 
127cdf0e10cSrcweir struct SbiGosubStack {				// GOSUB-Stack:
128cdf0e10cSrcweir 	SbiGosubStack* pNext;			// Chain
129cdf0e10cSrcweir 	const sal_uInt8* pCode;				// Return-Pointer
130cdf0e10cSrcweir 	sal_uInt16 nStartForLvl;			// #118235: For Level in moment of gosub
131cdf0e10cSrcweir };
132cdf0e10cSrcweir 
133cdf0e10cSrcweir #define MAXRECURSION 500            // max. 500 Rekursionen
134cdf0e10cSrcweir 
135cdf0e10cSrcweir #define Sb_ATTR_NORMAL		0x0000
136cdf0e10cSrcweir #define Sb_ATTR_HIDDEN 		0x0002
137cdf0e10cSrcweir #define Sb_ATTR_SYSTEM		0x0004
138cdf0e10cSrcweir #define Sb_ATTR_VOLUME		0x0008
139cdf0e10cSrcweir #define Sb_ATTR_DIRECTORY	0x0010
140cdf0e10cSrcweir #define Sb_ATTR_ARCHIVE		0x0020
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 
143cdf0e10cSrcweir class Dir;
144cdf0e10cSrcweir class WildCard;
145cdf0e10cSrcweir 
146cdf0e10cSrcweir class SbiRTLData
147cdf0e10cSrcweir {
148cdf0e10cSrcweir public:
149cdf0e10cSrcweir 
150cdf0e10cSrcweir #ifdef _OLD_FILE_IMPL
151cdf0e10cSrcweir 	Dir* 	pDir;
152cdf0e10cSrcweir #else
153cdf0e10cSrcweir 	::osl::Directory* pDir;
154cdf0e10cSrcweir #endif
155cdf0e10cSrcweir 	sal_Int16	nDirFlags;
156cdf0e10cSrcweir 	short	nCurDirPos;
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 	String sFullNameToBeChecked;
159cdf0e10cSrcweir 	WildCard* pWildCard;
160cdf0e10cSrcweir 
161cdf0e10cSrcweir #ifdef _USE_UNO
162cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aDirSeq;
163cdf0e10cSrcweir #endif /* _USE_UNO */
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 	SbiRTLData();
166cdf0e10cSrcweir 	~SbiRTLData();
167cdf0e10cSrcweir };
168cdf0e10cSrcweir 
169cdf0e10cSrcweir // Die Instanz entspricht einem laufenden StarBASIC. Mehrere gleichzeitig
170cdf0e10cSrcweir // laufende BASICs werden ueber verkettete Instanzen verwaltet. Hier liegen
171cdf0e10cSrcweir // alle Daten, die nur leben, wenn BASIC auch lebt, wie z.B. das I/O-System.
172cdf0e10cSrcweir 
173cdf0e10cSrcweir typedef ::std::vector
174cdf0e10cSrcweir <
175cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
176cdf0e10cSrcweir >
177cdf0e10cSrcweir ComponentVector_t;
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 
180cdf0e10cSrcweir class SbiInstance
181cdf0e10cSrcweir {
182cdf0e10cSrcweir 	friend class SbiRuntime;
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 	SbiRTLData		aRTLData;
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 	SbiIoSystem* 	pIosys;         // Dateisystem
187cdf0e10cSrcweir 	SbiDdeControl*	pDdeCtrl;       // DDE
188cdf0e10cSrcweir 	SbiDllMgr*		pDllMgr;		// DLL-Calls (DECLARE)
189cdf0e10cSrcweir 	StarBASIC*  	pBasic;
190cdf0e10cSrcweir 	SvNumberFormatter* pNumberFormatter;
191cdf0e10cSrcweir     LanguageType    meFormatterLangType;
192cdf0e10cSrcweir     DateFormat      meFormatterDateFormat;
193cdf0e10cSrcweir 	sal_uInt32 		nStdDateIdx, nStdTimeIdx, nStdDateTimeIdx;
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 	SbError      	nErr;     		// aktueller Fehlercode
196cdf0e10cSrcweir 	String		    aErrorMsg;		// letzte Error-Message fuer $ARG
197cdf0e10cSrcweir 	sal_uInt16      	nErl;			// aktuelle Fehlerzeile
198cdf0e10cSrcweir 	sal_Bool			bReschedule;	// Flag: sal_True = Reschedule in Hauptschleife
199cdf0e10cSrcweir 	sal_Bool			bCompatibility; // Flag: sal_True = VBA runtime compatibility mode
200cdf0e10cSrcweir 
201cdf0e10cSrcweir     ComponentVector_t ComponentVector;
202cdf0e10cSrcweir 
203cdf0e10cSrcweir public:
204cdf0e10cSrcweir 	SbiRuntime*  pRun;        		// Call-Stack
205cdf0e10cSrcweir 	SbiInstance* pNext;             // Instanzen-Chain
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 	// #31460 Neues Konzept fuer StepInto/Over/Out,
208cdf0e10cSrcweir 	// Erklaerung siehe runtime.cxx bei SbiInstance::CalcBreakCallLevel()
209cdf0e10cSrcweir 	sal_uInt16	nCallLvl;				// Call-Level (wg. Rekursion)
210cdf0e10cSrcweir 	sal_uInt16	nBreakCallLvl;			// Call-Level zum Anhalten
211cdf0e10cSrcweir 	void	CalcBreakCallLevel( sal_uInt16 nFlags );	// Gemaess Flags setzen
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 	SbiInstance( StarBASIC* );
214cdf0e10cSrcweir    ~SbiInstance();
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 	void Error( SbError );			            // trappable Error
217cdf0e10cSrcweir 	void Error( SbError, const String& rMsg );	// trappable Error mit Message
218cdf0e10cSrcweir 	void ErrorVB( sal_Int32 nVBNumber, const String& rMsg );
219cdf0e10cSrcweir 	void setErrorVB( sal_Int32 nVBNumber, const String& rMsg );
220cdf0e10cSrcweir 	void FatalError( SbError );		            // non-trappable Error
221cdf0e10cSrcweir 	void FatalError( SbError, const String& );  // non-trappable Error
222cdf0e10cSrcweir 	void Abort();					            // Abbruch mit aktuellem Fehlercode
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 	void    Stop();
GetErr()225cdf0e10cSrcweir 	SbError GetErr()				{ return nErr; }
GetErrorMsg()226cdf0e10cSrcweir 	String	GetErrorMsg()			{ return aErrorMsg; }
GetErl()227cdf0e10cSrcweir 	xub_StrLen GetErl()				{ return nErl; }
EnableReschedule(sal_Bool bEnable)228cdf0e10cSrcweir 	void	EnableReschedule( sal_Bool bEnable ) { bReschedule = bEnable; }
IsReschedule(void)229cdf0e10cSrcweir 	sal_Bool	IsReschedule( void ) { return bReschedule; }
EnableCompatibility(sal_Bool bEnable)230cdf0e10cSrcweir 	void	EnableCompatibility( sal_Bool bEnable ) { bCompatibility = bEnable; }
IsCompatibility(void)231cdf0e10cSrcweir 	sal_Bool	IsCompatibility( void ) { return bCompatibility; }
232cdf0e10cSrcweir 
getComponentVector(void)233cdf0e10cSrcweir     ComponentVector_t& getComponentVector( void )  { return ComponentVector; }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 	SbMethod* GetCaller( sal_uInt16 );
236cdf0e10cSrcweir 	SbModule* GetActiveModule();
237cdf0e10cSrcweir 	SbxArray* GetLocals( SbMethod* );
238cdf0e10cSrcweir 
GetIoSystem()239cdf0e10cSrcweir 	SbiIoSystem* GetIoSystem() { return pIosys; }
GetDdeControl()240cdf0e10cSrcweir 	SbiDdeControl* GetDdeControl() { return pDdeCtrl; }
GetBasic(void)241cdf0e10cSrcweir     StarBASIC* GetBasic( void ) { return pBasic; }
242cdf0e10cSrcweir 	SbiDllMgr* GetDllMgr();
GetRTLData() const243cdf0e10cSrcweir 	SbiRTLData* GetRTLData() const { return (SbiRTLData*)&aRTLData; }
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 	SvNumberFormatter* GetNumberFormatter();
GetStdDateIdx() const246cdf0e10cSrcweir 	sal_uInt32 GetStdDateIdx() const { return nStdDateIdx; }
GetStdTimeIdx() const247cdf0e10cSrcweir 	sal_uInt32 GetStdTimeIdx() const { return nStdTimeIdx; }
GetStdDateTimeIdx() const248cdf0e10cSrcweir 	sal_uInt32 GetStdDateTimeIdx() const { return nStdDateTimeIdx; }
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 	// #39629# NumberFormatter auch statisch anbieten
251cdf0e10cSrcweir 	static void PrepareNumberFormatter( SvNumberFormatter*& rpNumberFormatter,
252cdf0e10cSrcweir 		sal_uInt32 &rnStdDateIdx, sal_uInt32 &rnStdTimeIdx, sal_uInt32 &rnStdDateTimeIdx,
253cdf0e10cSrcweir         LanguageType* peFormatterLangType=NULL, DateFormat* peFormatterDateFormat=NULL );
254cdf0e10cSrcweir };
255cdf0e10cSrcweir 
256cdf0e10cSrcweir SbiIoSystem* SbGetIoSystem();		// das aktuelle I/O-System
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 
259cdf0e10cSrcweir // Verkettbare Items, um Referenzen temporaer zu halten
260cdf0e10cSrcweir struct RefSaveItem
261cdf0e10cSrcweir {
262cdf0e10cSrcweir 	SbxVariableRef xRef;
263cdf0e10cSrcweir 	RefSaveItem* pNext;
264cdf0e10cSrcweir 
RefSaveItemRefSaveItem265cdf0e10cSrcweir 	RefSaveItem() { pNext = NULL; }
266cdf0e10cSrcweir };
267cdf0e10cSrcweir 
268cdf0e10cSrcweir 
269cdf0e10cSrcweir // Eine Instanz dieser Klasse wird fuer jedes ausgefuehrte Unterprogramm
270cdf0e10cSrcweir // aufgesetzt. Diese Instanz ist das Herz der BASIC-Maschine und enthaelt
271cdf0e10cSrcweir // nur lokale Daten.
272cdf0e10cSrcweir 
273cdf0e10cSrcweir class SbiRuntime
274cdf0e10cSrcweir {
275cdf0e10cSrcweir 	friend void SbRtl_CallByName( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite );
276cdf0e10cSrcweir 
277cdf0e10cSrcweir 	typedef void( SbiRuntime::*pStep0 )();
278cdf0e10cSrcweir 	typedef void( SbiRuntime::*pStep1 )( sal_uInt32 nOp1 );
279cdf0e10cSrcweir 	typedef void( SbiRuntime::*pStep2 )( sal_uInt32 nOp1, sal_uInt32 nOp2 );
280cdf0e10cSrcweir 	static pStep0 aStep0[];         // Opcode-Tabelle Gruppe 0
281cdf0e10cSrcweir 	static pStep1 aStep1[];         // Opcode-Tabelle Gruppe 1
282cdf0e10cSrcweir 	static pStep2 aStep2[];         // Opcode-Tabelle Gruppe 2
283cdf0e10cSrcweir 
284cdf0e10cSrcweir 	StarBASIC&    rBasic; 			// StarBASIC-Instanz
285cdf0e10cSrcweir 	SbiInstance*   pInst;			// aktiver Thread
286cdf0e10cSrcweir 	SbModule*	  pMod;				// aktuelles Modul
287cdf0e10cSrcweir 	SbMethod* 	  pMeth;			// Methoden-Instanz
288cdf0e10cSrcweir 	SbiIoSystem*   pIosys;			// I/O-System
289cdf0e10cSrcweir 	const SbiImage* pImg;           // Code-Image
290cdf0e10cSrcweir 	SbxArrayRef   refExprStk;       // expression stack
291cdf0e10cSrcweir 	SbxArrayRef   refCaseStk;       // CASE expression stack
292cdf0e10cSrcweir 	SbxArrayRef   refRedimpArray;   // Array saved to use for REDIM PRESERVE
293cdf0e10cSrcweir 	SbxVariableRef xDummyVar;		// Ersatz fuer nicht gefundene Variablen
294cdf0e10cSrcweir 	SbiArgvStack*  pArgvStk;		// ARGV-Stack
295cdf0e10cSrcweir 	SbiGosubStack* pGosubStk;		// GOSUB stack
296cdf0e10cSrcweir 	SbiForStack*   pForStk;			// FOR/NEXT-Stack
297cdf0e10cSrcweir 	sal_uInt16        nExprLvl;			// Tiefe des Expr-Stacks
298cdf0e10cSrcweir 	sal_uInt16        nGosubLvl;        // Zum Vermeiden von Tot-Rekursionen
299cdf0e10cSrcweir 	sal_uInt16        nForLvl;	        // #118235: Maintain for level
300cdf0e10cSrcweir 	const sal_uInt8*   pCode;            // aktueller Code-Pointer
301cdf0e10cSrcweir 	const sal_uInt8*   pStmnt;           // Beginn des lezten Statements
302cdf0e10cSrcweir 	const sal_uInt8*   pError;           // Adresse des aktuellen Error-Handlers
303cdf0e10cSrcweir 	const sal_uInt8*   pRestart;         // Restart-Adresse
304cdf0e10cSrcweir 	const sal_uInt8*   pErrCode;         // Restart-Adresse RESUME NEXT
305cdf0e10cSrcweir 	const sal_uInt8*   pErrStmnt;        // Restart-Adresse RESUMT 0
306cdf0e10cSrcweir 	String		  aLibName;			// Lib-Name fuer Declare-Call
307cdf0e10cSrcweir 	SbxArrayRef   refParams;        // aktuelle Prozedur-Parameter
308cdf0e10cSrcweir 	SbxArrayRef   refLocals;        // lokale Variable
309cdf0e10cSrcweir 	SbxArrayRef   refArgv;          // aktueller Argv
310cdf0e10cSrcweir 	// AB, 28.3.2000 #74254, Ein refSaveObj reicht nicht! Neu: pRefSaveList (s.u.)
311cdf0e10cSrcweir 	//SbxVariableRef refSaveObj;      // #56368 Bei StepElem Referenz sichern
312cdf0e10cSrcweir 	short         nArgc;            // aktueller Argc
313cdf0e10cSrcweir 	sal_Bool          bRun;             // sal_True: Programm ist aktiv
314cdf0e10cSrcweir 	sal_Bool          bError;           // sal_True: Fehler behandeln
315cdf0e10cSrcweir 	sal_Bool          bInError;         // sal_True: in einem Fehler-Handler
316cdf0e10cSrcweir 	sal_Bool          bBlocked;         // sal_True: blocked by next call level, #i48868
317cdf0e10cSrcweir 	sal_Bool          bVBAEnabled;
318cdf0e10cSrcweir 	sal_uInt16		  nFlags;			// Debugging-Flags
319cdf0e10cSrcweir 	SbError		  nError;           // letzter Fehler
320cdf0e10cSrcweir 	sal_uInt16		  nOps;				// Opcode-Zaehler
321cdf0e10cSrcweir 	sal_uInt32    m_nLastTime;
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 	RefSaveItem*  pRefSaveList;     // #74254 Temporaere Referenzen sichern
324cdf0e10cSrcweir 	RefSaveItem*  pItemStoreList;   // Unbenutzte Items aufbewahren
SaveRef(SbxVariable * pVar)325cdf0e10cSrcweir 	void SaveRef( SbxVariable* pVar )
326cdf0e10cSrcweir 	{
327cdf0e10cSrcweir 		RefSaveItem* pItem = pItemStoreList;
328cdf0e10cSrcweir 		if( pItem )
329cdf0e10cSrcweir 			pItemStoreList = pItem->pNext;
330cdf0e10cSrcweir 		else
331cdf0e10cSrcweir 			pItem = new RefSaveItem();
332cdf0e10cSrcweir 		pItem->pNext = pRefSaveList;
333cdf0e10cSrcweir 		pItem->xRef = pVar;
334cdf0e10cSrcweir 		pRefSaveList = pItem;
335cdf0e10cSrcweir 	}
ClearRefs(void)336cdf0e10cSrcweir 	void ClearRefs( void )
337cdf0e10cSrcweir 	{
338cdf0e10cSrcweir 		while( pRefSaveList )
339cdf0e10cSrcweir 		{
340cdf0e10cSrcweir 			RefSaveItem* pToClearItem = pRefSaveList;
341cdf0e10cSrcweir 			pRefSaveList = pToClearItem->pNext;
342cdf0e10cSrcweir 			pToClearItem->xRef = NULL;
343cdf0e10cSrcweir 			pToClearItem->pNext = pItemStoreList;
344cdf0e10cSrcweir 			pItemStoreList = pToClearItem;
345cdf0e10cSrcweir 		}
346cdf0e10cSrcweir 	}
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 	SbxVariable* FindElement
349cdf0e10cSrcweir 	( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt32 nOp2, SbError, sal_Bool bLocal, sal_Bool bStatic = sal_False );
350cdf0e10cSrcweir 	void SetupArgs( SbxVariable*, sal_uInt32 );
351cdf0e10cSrcweir 	SbxVariable* CheckArray( SbxVariable* );
352cdf0e10cSrcweir 
353cdf0e10cSrcweir 	void PushVar( SbxVariable* );   // Variable push
354cdf0e10cSrcweir 	SbxVariableRef PopVar();          // Variable pop
355cdf0e10cSrcweir 	SbxVariable* GetTOS( short=0 ); // Variable vom TOS holen
356cdf0e10cSrcweir 	void TOSMakeTemp();				// TOS in temp. Variable wandeln
357cdf0e10cSrcweir 	sal_Bool ClearExprStack();          // Expr-Stack freigeben
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 	void PushGosub( const sal_uInt8* );  // GOSUB-Element push
360cdf0e10cSrcweir 	void PopGosub();                // GOSUB-Element pop
361cdf0e10cSrcweir 	void ClearGosubStack();         // GOSUB-Stack freigeben
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 	void PushArgv();                // Argv-Element push
364cdf0e10cSrcweir 	void PopArgv();                 // Argv-Element pop
365cdf0e10cSrcweir 	void ClearArgvStack();          // Argv-Stack freigeben
366cdf0e10cSrcweir 
367cdf0e10cSrcweir 	void PushFor();                 // For-Element push
368cdf0e10cSrcweir 	void PushForEach();             // For-Each-Element push
369cdf0e10cSrcweir 	void PopFor();                  // For-Element pop
370cdf0e10cSrcweir 	void ClearForStack();           // For-Stack freigeben
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 	void StepArith( SbxOperator );  // arithmetische Verknuepfungen
373cdf0e10cSrcweir 	void StepUnary( SbxOperator );  // unaere Verknuepfungen
374cdf0e10cSrcweir 	void StepCompare( SbxOperator );// Vergleiche
375cdf0e10cSrcweir 
376cdf0e10cSrcweir 	void SetParameters( SbxArray* );// Parameter uebernehmen
377cdf0e10cSrcweir 
378cdf0e10cSrcweir 	// MUSS NOCH IMPLEMENTIERT WERDEN
379cdf0e10cSrcweir 	void DllCall( const String&, const String&, SbxArray*, SbxDataType, sal_Bool );
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 	// #56204 DIM-Funktionalitaet in Hilfsmethode auslagern (step0.cxx)
382cdf0e10cSrcweir 	void DimImpl( SbxVariableRef refVar );
383cdf0e10cSrcweir 
384cdf0e10cSrcweir 	// #115829
385cdf0e10cSrcweir 	bool implIsClass( SbxObject* pObj, const String& aClass );
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 	void StepSETCLASS_impl( sal_uInt32 nOp1, bool bHandleDflt = false );
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 	// Die nachfolgenden Routinen werden vom Single Stepper
390cdf0e10cSrcweir 	// gerufen und implementieren die einzelnen Opcodes
391cdf0e10cSrcweir 	void StepNOP(),     StepEXP(),      StepMUL(),      StepDIV();
392cdf0e10cSrcweir 	void StepMOD(),     StepPLUS(),     StepMINUS(),    StepNEG();
393cdf0e10cSrcweir 	void StepEQ(),      StepNE(),       StepLT(),       StepGT();
394cdf0e10cSrcweir 	void StepLE(),      StepGE(),       StepIDIV(),     StepAND();
395cdf0e10cSrcweir 	void StepOR(),      StepXOR(),      StepEQV(),      StepIMP();
396cdf0e10cSrcweir 	void StepNOT(),     StepCAT(),      StepLIKE(),     StepIS();
397cdf0e10cSrcweir 	void StepCLONE(),   StepOLDBASED(), StepARGC();
398cdf0e10cSrcweir 	void StepARGV(),    StepINPUT(),	StepLINPUT(),	StepSTOP();
399cdf0e10cSrcweir 	void StepGET(),		StepSET(),	StepVBASET(), 	StepPUT(),		StepPUTC();
400cdf0e10cSrcweir 	void StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, bool bDefaultHandling = false );
401cdf0e10cSrcweir 	void StepDIM(),     StepREDIM(),	StepREDIMP(),	StepERASE();
402cdf0e10cSrcweir 	void StepINITFOR(), StepNEXT(),		StepERROR(),	StepINITFOREACH();
403cdf0e10cSrcweir 	void StepCASE(),	StepENDCASE(),  StepSTDERROR();
404cdf0e10cSrcweir 	void StepNOERROR(), StepCHANNEL(),  StepCHANNEL0(),	StepPRINT();
405cdf0e10cSrcweir 	void StepPRINTF(),	StepWRITE(),    StepRENAME(),   StepPROMPT();
406cdf0e10cSrcweir 	void StepRESTART(), StepEMPTY(),    StepLEAVE();
407cdf0e10cSrcweir 	void StepLSET(),	StepRSET(),		StepREDIMP_ERASE(), 	StepERASE_CLEAR();
408cdf0e10cSrcweir 	void StepARRAYACCESS(), StepBYVAL();
409cdf0e10cSrcweir 	// Alle Opcodes mit einem Operanden
410cdf0e10cSrcweir 	void StepLOADNC( sal_uInt32 ),  StepLOADSC( sal_uInt32 ),   StepLOADI( sal_uInt32 );
411cdf0e10cSrcweir 	void StepARGN( sal_uInt32 ),	StepBASED( sal_uInt32 ),	StepPAD( sal_uInt32 );
412cdf0e10cSrcweir 	void StepJUMP( sal_uInt32 ),    StepJUMPT( sal_uInt32 );
413cdf0e10cSrcweir 	void StepJUMPF( sal_uInt32 ),   StepONJUMP( sal_uInt32 );
414cdf0e10cSrcweir 	void StepGOSUB( sal_uInt32 ),   StepRETURN( sal_uInt32 );
415cdf0e10cSrcweir 	void StepTESTFOR( sal_uInt32 ), StepCASETO( sal_uInt32 ),   StepERRHDL( sal_uInt32 );
416cdf0e10cSrcweir 	void StepRESUME( sal_uInt32 ),  StepSETCLASS( sal_uInt32 ),	StepVBASETCLASS( sal_uInt32 ),	StepTESTCLASS( sal_uInt32 ), StepLIB( sal_uInt32 );
417cdf0e10cSrcweir 	bool checkClass_Impl( const SbxVariableRef& refVal, const String& aClass, bool bRaiseErrors, bool bDefault = true );
418cdf0e10cSrcweir 	void StepCLOSE( sal_uInt32 ),   StepPRCHAR( sal_uInt32 ),   StepARGTYP( sal_uInt32 );
419cdf0e10cSrcweir 	// Alle Opcodes mit zwei Operanden
420cdf0e10cSrcweir 	void StepRTL( sal_uInt32, sal_uInt32 ),		StepPUBLIC( sal_uInt32, sal_uInt32 ),	StepPUBLIC_P( sal_uInt32, sal_uInt32 );
421cdf0e10cSrcweir 	void StepPUBLIC_Impl( sal_uInt32, sal_uInt32, bool bUsedForClassModule );
422cdf0e10cSrcweir 	void StepFIND_Impl( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt32 nOp2, SbError, sal_Bool bLocal, sal_Bool bStatic = sal_False );
423cdf0e10cSrcweir 	void StepFIND( sal_uInt32, sal_uInt32 ),    StepELEM( sal_uInt32, sal_uInt32 );
424cdf0e10cSrcweir 	void StepGLOBAL( sal_uInt32, sal_uInt32 ),  StepLOCAL( sal_uInt32, sal_uInt32 );
425cdf0e10cSrcweir 	void StepPARAM( sal_uInt32, sal_uInt32), 	StepCREATE( sal_uInt32, sal_uInt32 );
426cdf0e10cSrcweir 	void StepCALL( sal_uInt32, sal_uInt32 ),    StepCALLC( sal_uInt32, sal_uInt32 );
427cdf0e10cSrcweir 	void StepCASEIS( sal_uInt32, sal_uInt32 ),  StepSTMNT( sal_uInt32, sal_uInt32 );
428cdf0e10cSrcweir 	SbxVariable* StepSTATIC_Impl( String& aName, SbxDataType& t );
429cdf0e10cSrcweir 	void StepOPEN( sal_uInt32, sal_uInt32 ),	StepSTATIC( sal_uInt32, sal_uInt32 );
430cdf0e10cSrcweir 	void StepTCREATE(sal_uInt32,sal_uInt32),	StepDCREATE(sal_uInt32,sal_uInt32);
431cdf0e10cSrcweir 	void StepGLOBAL_P( sal_uInt32, sal_uInt32 ),StepFIND_G( sal_uInt32, sal_uInt32 );
432cdf0e10cSrcweir 	void StepDCREATE_REDIMP(sal_uInt32,sal_uInt32), StepDCREATE_IMPL(sal_uInt32,sal_uInt32);
433cdf0e10cSrcweir 	void StepFIND_CM( sal_uInt32, sal_uInt32 );
434cdf0e10cSrcweir 	void StepFIND_STATIC( sal_uInt32, sal_uInt32 );
435cdf0e10cSrcweir 	void implHandleSbxFlags( SbxVariable* pVar, SbxDataType t, sal_uInt32 nOp2 );
436cdf0e10cSrcweir public:
437cdf0e10cSrcweir 	void          SetVBAEnabled( bool bEnabled );
438cdf0e10cSrcweir 	sal_uInt16		GetImageFlag( sal_uInt16 n ) const;
439cdf0e10cSrcweir 	sal_uInt16		GetBase();
440cdf0e10cSrcweir 	xub_StrLen  nLine,nCol1,nCol2;	// aktuelle Zeile, Spaltenbereich
441cdf0e10cSrcweir 	SbiRuntime* pNext;               // Stack-Chain
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 	SbiRuntime( SbModule*, SbMethod*, sal_uInt32 );
444cdf0e10cSrcweir    ~SbiRuntime();
445cdf0e10cSrcweir 	void Error( SbError, bool bVBATranslationAlreadyDone = false );		// Fehler setzen, falls != 0
446cdf0e10cSrcweir 	void Error( SbError, const String& );       // Fehler setzen, falls != 0
447cdf0e10cSrcweir 	void FatalError( SbError );		            // Fehlerbehandlung=Standard, Fehler setzen
448cdf0e10cSrcweir 	void FatalError( SbError, const String& );  // Fehlerbehandlung=Standard, Fehler setzen
449cdf0e10cSrcweir 	static sal_Int32 translateErrorToVba( SbError nError, String& rMsg );
450cdf0e10cSrcweir 	void DumpPCode();
451cdf0e10cSrcweir 	sal_Bool Step();                    // Einzelschritt (ein Opcode)
Stop()452cdf0e10cSrcweir 	void Stop()     	   { bRun = sal_False;   }
IsRun()453cdf0e10cSrcweir     sal_Bool IsRun()           { return bRun;    }
block(void)454cdf0e10cSrcweir 	void block( void )	   { bBlocked = sal_True; }
unblock(void)455cdf0e10cSrcweir 	void unblock( void )   { bBlocked = sal_False; }
GetMethod()456cdf0e10cSrcweir 	SbMethod* GetMethod()  { return pMeth;   }
GetModule()457cdf0e10cSrcweir 	SbModule* GetModule()  { return pMod;    }
GetDebugFlags()458cdf0e10cSrcweir 	sal_uInt16 GetDebugFlags() { return nFlags;  }
SetDebugFlags(sal_uInt16 nFl)459cdf0e10cSrcweir 	void SetDebugFlags( sal_uInt16 nFl ) { nFlags = nFl;  }
460cdf0e10cSrcweir 	SbMethod* GetCaller();
461cdf0e10cSrcweir 	SbxArray* GetLocals();
462cdf0e10cSrcweir 	SbxArray* GetParams();
463cdf0e10cSrcweir 
464cdf0e10cSrcweir 	SbiForStack* FindForStackItemForCollection( class BasicCollection* pCollection );
465cdf0e10cSrcweir 
466cdf0e10cSrcweir 	SbxBase* FindElementExtern( const String& rName );
467cdf0e10cSrcweir 	static bool isVBAEnabled();
468cdf0e10cSrcweir 
469cdf0e10cSrcweir };
470cdf0e10cSrcweir 
checkArithmeticOverflow(double d)471cdf0e10cSrcweir inline void checkArithmeticOverflow( double d )
472cdf0e10cSrcweir {
473cdf0e10cSrcweir     if( !::rtl::math::isFinite( d ) )
474cdf0e10cSrcweir     	StarBASIC::Error( SbERR_MATH_OVERFLOW );
475cdf0e10cSrcweir }
476cdf0e10cSrcweir 
checkArithmeticOverflow(SbxVariable * pVar)477cdf0e10cSrcweir inline void checkArithmeticOverflow( SbxVariable* pVar )
478cdf0e10cSrcweir {
479cdf0e10cSrcweir     if( pVar->GetType() == SbxDOUBLE )
480cdf0e10cSrcweir     {
481cdf0e10cSrcweir         double d = pVar->GetDouble();
482cdf0e10cSrcweir         checkArithmeticOverflow( d );
483cdf0e10cSrcweir     }
484cdf0e10cSrcweir }
485cdf0e10cSrcweir 
486cdf0e10cSrcweir // Hilfsfunktion, um aktives Basic zu finden
487cdf0e10cSrcweir StarBASIC* GetCurrentBasic( StarBASIC* pRTBasic );
488cdf0e10cSrcweir 
489cdf0e10cSrcweir // Get information if security restrictions should be
490cdf0e10cSrcweir // used (File IO based on UCB, no RTL function SHELL
491cdf0e10cSrcweir // no DDE functionality, no DLLCALL) in basic because
492cdf0e10cSrcweir // of portal "virtual" users (portal user != UNIX user)
493cdf0e10cSrcweir // (Implemented in iosys.cxx)
494cdf0e10cSrcweir sal_Bool needSecurityRestrictions( void );
495cdf0e10cSrcweir 
496cdf0e10cSrcweir // Returns sal_True if UNO is available, otherwise the old
497cdf0e10cSrcweir // file system implementation has to be used
498cdf0e10cSrcweir // (Implemented in iosys.cxx)
499cdf0e10cSrcweir sal_Bool hasUno( void );
500cdf0e10cSrcweir 
501cdf0e10cSrcweir // Converts possibly relative paths to absolute paths
502cdf0e10cSrcweir // according to the setting done by ChDir/ChDrive
503cdf0e10cSrcweir // (Implemented in methods.cxx)
504cdf0e10cSrcweir String getFullPath( const String& aRelPath );
505cdf0e10cSrcweir 
506cdf0e10cSrcweir // Sets (virtual) current path for UCB file access
507cdf0e10cSrcweir void implChDir( const String& aDir );
508cdf0e10cSrcweir 
509cdf0e10cSrcweir // Sets (virtual) current drive for UCB file access
510cdf0e10cSrcweir void implChDrive( const String& aDrive );
511cdf0e10cSrcweir 
512cdf0e10cSrcweir // Returns (virtual) current path for UCB file access
513cdf0e10cSrcweir String implGetCurDir( void );
514cdf0e10cSrcweir 
515cdf0e10cSrcweir // Implementation of StepRENAME with UCB
516cdf0e10cSrcweir // (Implemented in methods.cxx, so step0.cxx
517cdf0e10cSrcweir // has not to be infected with UNO)
518cdf0e10cSrcweir void implStepRenameUCB( const String& aSource, const String& aDest );
519cdf0e10cSrcweir 
520cdf0e10cSrcweir //*** OSL file access ***
521cdf0e10cSrcweir // #87427 OSL need File URLs, so map to getFullPath
getFullPathUNC(const String & aRelPath)522cdf0e10cSrcweir inline String getFullPathUNC( const String& aRelPath )
523cdf0e10cSrcweir {
524cdf0e10cSrcweir     return getFullPath( aRelPath );
525cdf0e10cSrcweir }
526cdf0e10cSrcweir void implStepRenameOSL( const String& aSource, const String& aDest );
527cdf0e10cSrcweir bool IsBaseIndexOne();
528cdf0e10cSrcweir 
529cdf0e10cSrcweir #endif
530cdf0e10cSrcweir 
531