2010-10-27 13:11:31 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 15:18:56 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 11:00:13 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-11 11:00:13 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-11 11:00:13 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-11 11:00:13 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-11 11:00:13 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-11 11:00:13 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _SYMTBL_HXX
|
|
|
|
#define _SYMTBL_HXX
|
|
|
|
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/svarray.hxx>
|
2000-09-18 15:18:56 +00:00
|
|
|
#include <tools/string.hxx>
|
2007-06-27 13:24:09 +00:00
|
|
|
#include <basic/sbxdef.hxx>
|
|
|
|
#include <basic/sbdef.hxx>
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
class SbiSymDef; // Basisklasse
|
|
|
|
class SbiProcDef; // Prozedur
|
|
|
|
class SbiConstDef; // Konstante
|
|
|
|
class SbiSymPool; // Symbol-Pool
|
|
|
|
class SbiStringPool; // gepoolte Strings
|
|
|
|
|
|
|
|
class SvStream;
|
|
|
|
class SbiParser;
|
|
|
|
|
|
|
|
enum SbiSymScope { SbLOCAL, SbPARAM, SbPUBLIC, SbGLOBAL, SbRTL };
|
|
|
|
|
|
|
|
|
|
|
|
// Der String-Pool nimmt String-Eintraege auf und sorgt dafuer,
|
|
|
|
// dass sie nicht doppelt vorkommen.
|
|
|
|
|
|
|
|
SV_DECL_PTRARR_DEL(SbiStrings,String*,5,5)
|
|
|
|
|
|
|
|
class SbiStringPool { // String-Pool
|
|
|
|
SbiStrings aData; // Daten
|
|
|
|
String aEmpty; // for convenience
|
|
|
|
SbiParser* pParser; // der Parser
|
|
|
|
public:
|
|
|
|
SbiStringPool( SbiParser* );
|
|
|
|
~SbiStringPool();
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt16 GetSize() const { return aData.Count(); }
|
|
|
|
// AB 8.4.1999, Default wegen #64236 auf sal_True geaendert
|
|
|
|
// Wenn der Bug sauber behoben ist, wieder auf sal_False aendern.
|
|
|
|
short Add( const String&, sal_Bool=sal_True );
|
2000-09-18 15:18:56 +00:00
|
|
|
short Add( double, SbxDataType );
|
2011-01-10 14:40:57 +01:00
|
|
|
const String& Find( sal_uInt16 ) const;
|
2000-09-18 15:18:56 +00:00
|
|
|
SbiParser* GetParser() { return pParser; }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
SV_DECL_PTRARR_DEL(SbiSymbols,SbiSymDef*,5,5)
|
|
|
|
|
|
|
|
class SbiSymPool { // Symbol-Pool
|
|
|
|
friend class SbiSymDef;
|
|
|
|
friend class SbiProcDef;
|
|
|
|
protected:
|
|
|
|
SbiStringPool& rStrings; // verwendeter Stringpool
|
|
|
|
SbiSymbols aData; // Daten
|
|
|
|
SbiSymPool* pParent; // uebergeordneter Symbol-Pool
|
|
|
|
SbiParser* pParser; // der Parser
|
|
|
|
SbiSymScope eScope; // Scope des Pools
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt16 nProcId; // aktuelles ProcId fuer STATIC-Variable
|
|
|
|
sal_uInt16 nCur; // Iterator
|
2000-09-18 15:18:56 +00:00
|
|
|
public:
|
|
|
|
SbiSymPool( SbiStringPool&, SbiSymScope );
|
|
|
|
~SbiSymPool();
|
|
|
|
|
|
|
|
void Clear();
|
|
|
|
|
|
|
|
void SetParent( SbiSymPool* p ) { pParent = p; }
|
|
|
|
void SetProcId( short n ) { nProcId = n; }
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt16 GetSize() const { return aData.Count(); }
|
2000-09-18 15:18:56 +00:00
|
|
|
SbiSymScope GetScope() const { return eScope; }
|
|
|
|
void SetScope( SbiSymScope s ) { eScope = s; }
|
|
|
|
SbiParser* GetParser() { return pParser; }
|
|
|
|
|
|
|
|
SbiSymDef* AddSym( const String& ); // Symbol hinzufuegen
|
|
|
|
SbiProcDef* AddProc( const String& );// Prozedur hinzufuegen
|
|
|
|
void Add( SbiSymDef* ); // Symbol uebernehmen
|
|
|
|
SbiSymDef* Find( const String& ) const;// Variablenname
|
2011-01-10 14:40:57 +01:00
|
|
|
SbiSymDef* FindId( sal_uInt16 ) const; // Variable per ID suchen
|
|
|
|
SbiSymDef* Get( sal_uInt16 ) const; // Variable per Position suchen
|
2000-09-18 15:18:56 +00:00
|
|
|
SbiSymDef* First(), *Next(); // Iteratoren
|
|
|
|
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt32 Define( const String& ); // Label definieren
|
|
|
|
sal_uInt32 Reference( const String& ); // Label referenzieren
|
2000-09-18 15:18:56 +00:00
|
|
|
void CheckRefs(); // offene Referenzen suchen
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SbiSymDef { // Allgemeiner Symboleintrag
|
|
|
|
friend class SbiSymPool;
|
|
|
|
protected:
|
|
|
|
String aName; // Name des Eintrags
|
|
|
|
SbxDataType eType; // Typ des Eintrags
|
|
|
|
SbiSymPool* pIn; // Parent-Pool
|
|
|
|
SbiSymPool* pPool; // Pool fuer Unterelemente
|
|
|
|
short nLen; // Stringlaenge bei STRING*n
|
|
|
|
short nDims; // Array-Dimensionen
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt16 nId; // Symbol-Nummer
|
|
|
|
sal_uInt16 nTypeId; // String-ID des Datentyps (Dim X AS Dytentyp)
|
|
|
|
sal_uInt16 nProcId; // aktuelles ProcId fuer STATIC-Variable
|
|
|
|
sal_uInt16 nPos; // Positions-Nummer
|
|
|
|
sal_uInt32 nChain; // Backchain-Kette
|
|
|
|
sal_Bool bNew : 1; // sal_True: Dim As New...
|
|
|
|
sal_Bool bChained : 1; // sal_True: Symbol ist in Code definiert
|
|
|
|
sal_Bool bByVal : 1; // sal_True: ByVal-Parameter
|
|
|
|
sal_Bool bOpt : 1; // sal_True: optionaler Parameter
|
|
|
|
sal_Bool bStatic : 1; // sal_True: STATIC-Variable
|
|
|
|
sal_Bool bAs : 1; // sal_True: Datentyp per AS XXX definiert
|
|
|
|
sal_Bool bGlobal : 1; // sal_True: Global-Variable
|
|
|
|
sal_Bool bParamArray : 1; // sal_True: ParamArray parameter
|
|
|
|
sal_Bool bWithEvents : 1; // sal_True: Declared WithEvents
|
2011-03-25 10:40:25 +01:00
|
|
|
sal_Bool bWithBrackets : 1; // sal_True: Followed by ()
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt16 nDefaultId; // Symbol number of default value
|
2010-06-15 20:02:53 +02:00
|
|
|
short nFixedStringLength; // String length in: Dim foo As String*Length
|
2000-09-18 15:18:56 +00:00
|
|
|
public:
|
|
|
|
SbiSymDef( const String& );
|
|
|
|
virtual ~SbiSymDef();
|
|
|
|
virtual SbiProcDef* GetProcDef();
|
|
|
|
virtual SbiConstDef* GetConstDef();
|
|
|
|
|
|
|
|
SbxDataType GetType() const { return eType; }
|
|
|
|
virtual void SetType( SbxDataType );
|
|
|
|
const String& GetName();
|
|
|
|
SbiSymScope GetScope() const;
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt16 GetProcId() const{ return nProcId; }
|
|
|
|
sal_uInt32 GetAddr() const { return nChain; }
|
|
|
|
sal_uInt16 GetId() const { return nId; }
|
|
|
|
sal_uInt16 GetTypeId() const{ return nTypeId; }
|
|
|
|
void SetTypeId( sal_uInt16 n ) { nTypeId = n; eType = SbxOBJECT; }
|
|
|
|
sal_uInt16 GetPos() const { return nPos; }
|
2000-09-18 15:18:56 +00:00
|
|
|
void SetLen( short n ){ nLen = n; }
|
|
|
|
short GetLen() const { return nLen; }
|
|
|
|
void SetDims( short n ) { nDims = n; }
|
|
|
|
short GetDims() const { return nDims; }
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_Bool IsDefined() const{ return bChained; }
|
|
|
|
void SetOptional() { bOpt = sal_True; }
|
|
|
|
void SetParamArray() { bParamArray = sal_True; }
|
|
|
|
void SetWithEvents() { bWithEvents = sal_True; }
|
2011-03-25 10:40:25 +01:00
|
|
|
void SetWithBrackets(){ bWithBrackets = sal_True; }
|
2011-01-10 14:40:57 +01:00
|
|
|
void SetByVal( sal_Bool bByVal_ = sal_True )
|
2010-08-06 09:35:51 +02:00
|
|
|
{ bByVal = bByVal_; }
|
2011-01-10 14:40:57 +01:00
|
|
|
void SetStatic( sal_Bool bAsStatic = sal_True ) { bStatic = bAsStatic; }
|
|
|
|
void SetNew() { bNew = sal_True; }
|
|
|
|
void SetDefinedAs() { bAs = sal_True; }
|
|
|
|
void SetGlobal(sal_Bool b){ bGlobal = b; }
|
|
|
|
void SetDefaultId( sal_uInt16 n ) { nDefaultId = n; }
|
|
|
|
sal_uInt16 GetDefaultId( void ) { return nDefaultId; }
|
|
|
|
sal_Bool IsOptional() const{ return bOpt; }
|
|
|
|
sal_Bool IsParamArray() const{ return bParamArray; }
|
|
|
|
sal_Bool IsWithEvents() const{ return bWithEvents; }
|
2011-03-25 10:40:25 +01:00
|
|
|
sal_Bool IsWithBrackets() const{ return bWithBrackets; }
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_Bool IsByVal() const { return bByVal; }
|
|
|
|
sal_Bool IsStatic() const { return bStatic; }
|
|
|
|
sal_Bool IsNew() const { return bNew; }
|
|
|
|
sal_Bool IsDefinedAs() const { return bAs; }
|
|
|
|
sal_Bool IsGlobal() const { return bGlobal; }
|
2010-06-15 20:02:53 +02:00
|
|
|
short GetFixedStringLength( void ) const { return nFixedStringLength; }
|
|
|
|
void SetFixedStringLength( short n ) { nFixedStringLength = n; }
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
SbiSymPool& GetPool();
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt32 Define(); // Symbol in Code definieren
|
|
|
|
sal_uInt32 Reference(); // Symbol in Code referenzieren
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SbiSymDef( const SbiSymDef& );
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class SbiProcDef : public SbiSymDef { // Prozedur-Definition (aus Basic):
|
|
|
|
SbiSymPool aParams; // Parameter
|
|
|
|
SbiSymPool aLabels; // lokale Sprungziele
|
|
|
|
String aLibName; // LIB "name"
|
|
|
|
String aAlias; // ALIAS "name"
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt16 nLine1, nLine2; // Zeilenbereich
|
2004-11-02 10:56:50 +00:00
|
|
|
PropertyMode mePropMode; // Marks if this is a property procedure and which
|
|
|
|
String maPropName; // Property name if property procedure (!= proc name)
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_Bool bCdecl : 1; // sal_True: CDECL angegeben
|
|
|
|
sal_Bool bPublic : 1; // sal_True: proc ist PUBLIC
|
|
|
|
sal_Bool mbProcDecl : 1; // sal_True: instanciated by SbiParser::ProcDecl
|
2000-09-18 15:18:56 +00:00
|
|
|
public:
|
2011-01-10 14:40:57 +01:00
|
|
|
SbiProcDef( SbiParser*, const String&, sal_Bool bProcDecl=false );
|
2000-09-18 15:18:56 +00:00
|
|
|
virtual ~SbiProcDef();
|
|
|
|
virtual SbiProcDef* GetProcDef();
|
|
|
|
virtual void SetType( SbxDataType );
|
|
|
|
SbiSymPool& GetParams() { return aParams; }
|
|
|
|
SbiSymPool& GetLabels() { return aLabels; }
|
|
|
|
SbiSymPool& GetLocals() { return GetPool();}
|
|
|
|
String& GetLib() { return aLibName; }
|
|
|
|
String& GetAlias() { return aAlias; }
|
2011-01-10 14:40:57 +01:00
|
|
|
void SetPublic( sal_Bool b ) { bPublic = b; }
|
|
|
|
sal_Bool IsPublic() const { return bPublic; }
|
|
|
|
void SetCdecl( sal_Bool b = sal_True) { bCdecl = b; }
|
|
|
|
sal_Bool IsCdecl() const { return bCdecl; }
|
|
|
|
sal_Bool IsUsedForProcDecl() const { return mbProcDecl; }
|
|
|
|
void SetLine1( sal_uInt16 n ) { nLine1 = n; }
|
|
|
|
sal_uInt16 GetLine1() const { return nLine1; }
|
|
|
|
void SetLine2( sal_uInt16 n ) { nLine2 = n; }
|
|
|
|
sal_uInt16 GetLine2() const { return nLine2; }
|
2004-11-02 10:56:50 +00:00
|
|
|
PropertyMode getPropertyMode() { return mePropMode; }
|
|
|
|
void setPropertyMode( PropertyMode ePropMode );
|
|
|
|
const String& GetPropName() { return maPropName; }
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// Match mit einer Forward-Deklaration. Die Parameternamen
|
|
|
|
// werden abgeglichen und die Forward-Deklaration wird
|
|
|
|
// durch this ersetzt
|
|
|
|
void Match( SbiProcDef* pForward );
|
|
|
|
|
|
|
|
private:
|
|
|
|
SbiProcDef( const SbiProcDef& );
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class SbiConstDef : public SbiSymDef
|
|
|
|
{
|
|
|
|
double nVal;
|
|
|
|
String aVal;
|
|
|
|
public:
|
|
|
|
SbiConstDef( const String& );
|
|
|
|
virtual ~SbiConstDef();
|
|
|
|
virtual SbiConstDef* GetConstDef();
|
|
|
|
void Set( double, SbxDataType );
|
|
|
|
void Set( const String& );
|
|
|
|
double GetValue() { return nVal; }
|
|
|
|
const String& GetString() { return aVal; }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-10-27 13:11:31 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|