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