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
|
|
|
|
|
2012-06-10 12:47:02 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
class SbiConstDef;
|
2000-09-18 15:18:56 +00:00
|
|
|
class SbiParser;
|
2011-11-20 23:32:13 -05:00
|
|
|
class SbiProcDef;
|
|
|
|
class SbiStringPool;
|
|
|
|
class SbiSymDef; // base class
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
enum SbiSymScope { SbLOCAL, SbPARAM, SbPUBLIC, SbGLOBAL, SbRTL };
|
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
// The string-pool collects string entries and
|
|
|
|
// makes sure that they don't exist twice.
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
class SbiStringPool {
|
2011-11-20 23:44:21 -05:00
|
|
|
const rtl::OUString aEmpty;
|
2011-11-26 00:06:05 -05:00
|
|
|
std::vector<rtl::OUString> aData;
|
2011-08-27 21:37:14 +02:00
|
|
|
SbiParser* pParser;
|
2000-09-18 15:18:56 +00:00
|
|
|
public:
|
|
|
|
SbiStringPool( SbiParser* );
|
|
|
|
~SbiStringPool();
|
2011-11-20 23:44:21 -05:00
|
|
|
sal_uInt32 GetSize() const { return aData.size(); }
|
2011-08-27 21:37:14 +02:00
|
|
|
// From 8.4.1999: default changed to sal_True because of #64236 -
|
|
|
|
// change it back to sal_False when the bug is cleanly removed.
|
2011-11-20 23:44:21 -05:00
|
|
|
short Add( const rtl::OUString&, sal_Bool=sal_True );
|
2000-09-18 15:18:56 +00:00
|
|
|
short Add( double, SbxDataType );
|
2011-11-20 23:44:21 -05:00
|
|
|
const rtl::OUString& Find( sal_uInt32 ) const;
|
2000-09-18 15:18:56 +00:00
|
|
|
SbiParser* GetParser() { return pParser; }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-06-10 12:47:02 +02:00
|
|
|
class SbiSymbols : public std::vector<SbiSymDef*>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~SbiSymbols();
|
|
|
|
};
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
class SbiSymPool {
|
2000-09-18 15:18:56 +00:00
|
|
|
friend class SbiSymDef;
|
|
|
|
friend class SbiProcDef;
|
|
|
|
protected:
|
2011-08-27 21:37:14 +02:00
|
|
|
SbiStringPool& rStrings;
|
|
|
|
SbiSymbols aData;
|
|
|
|
SbiSymPool* pParent;
|
|
|
|
SbiParser* pParser;
|
|
|
|
SbiSymScope eScope;
|
|
|
|
sal_uInt16 nProcId; // for STATIC-variable
|
|
|
|
sal_uInt16 nCur; // iterator
|
2000-09-18 15:18:56 +00:00
|
|
|
public:
|
|
|
|
SbiSymPool( SbiStringPool&, SbiSymScope );
|
|
|
|
~SbiSymPool();
|
|
|
|
|
|
|
|
void SetParent( SbiSymPool* p ) { pParent = p; }
|
|
|
|
void SetProcId( short n ) { nProcId = n; }
|
2012-06-10 12:47:02 +02:00
|
|
|
sal_uInt16 GetSize() const { return aData.size(); }
|
2000-09-18 15:18:56 +00:00
|
|
|
SbiSymScope GetScope() const { return eScope; }
|
|
|
|
void SetScope( SbiSymScope s ) { eScope = s; }
|
|
|
|
SbiParser* GetParser() { return pParser; }
|
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
SbiSymDef* AddSym( const String& );
|
|
|
|
SbiProcDef* AddProc( const String& );
|
|
|
|
void Add( SbiSymDef* );
|
|
|
|
SbiSymDef* Find( const String& ) const; // variable name
|
|
|
|
SbiSymDef* FindId( sal_uInt16 ) const;
|
|
|
|
SbiSymDef* Get( sal_uInt16 ) const; // find variable per position
|
|
|
|
SbiSymDef* First(), *Next(); // iterators
|
|
|
|
|
|
|
|
sal_uInt32 Define( const String& );
|
|
|
|
sal_uInt32 Reference( const String& );
|
|
|
|
void CheckRefs();
|
2000-09-18 15:18:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
class SbiSymDef { // general symbol entry
|
2000-09-18 15:18:56 +00:00
|
|
|
friend class SbiSymPool;
|
|
|
|
protected:
|
2011-08-27 21:37:14 +02:00
|
|
|
String aName;
|
|
|
|
SbxDataType eType;
|
|
|
|
SbiSymPool* pIn; // parent pool
|
|
|
|
SbiSymPool* pPool; // pool for sub-elements
|
|
|
|
short nLen; // string length for STRING*n
|
|
|
|
short nDims;
|
|
|
|
sal_uInt16 nId;
|
|
|
|
sal_uInt16 nTypeId; // Dim X AS data type
|
|
|
|
sal_uInt16 nProcId;
|
|
|
|
sal_uInt16 nPos;
|
|
|
|
sal_uInt32 nChain;
|
2011-11-26 00:16:58 -05:00
|
|
|
bool bNew : 1; // true: Dim As New...
|
|
|
|
bool bChained : 1; // true: symbol is defined in code
|
|
|
|
bool bByVal : 1; // true: ByVal-parameter
|
|
|
|
bool bOpt : 1; // true: optional parameter
|
|
|
|
bool bStatic : 1; // true: STATIC variable
|
|
|
|
bool bAs : 1; // true: data type defined per AS XXX
|
|
|
|
bool bGlobal : 1; // true: global variable
|
|
|
|
bool bParamArray : 1; // true: ParamArray parameter
|
|
|
|
bool bWithEvents : 1; // true: Declared WithEvents
|
|
|
|
bool bWithBrackets : 1; // 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-11-26 00:16:58 -05:00
|
|
|
bool IsDefined() const{ return bChained; }
|
|
|
|
void SetOptional() { bOpt = true; }
|
|
|
|
void SetParamArray() { bParamArray = true; }
|
|
|
|
void SetWithEvents() { bWithEvents = true; }
|
|
|
|
void SetWithBrackets(){ bWithBrackets = true; }
|
|
|
|
void SetByVal( bool bByVal_ = true )
|
2010-08-06 09:35:51 +02:00
|
|
|
{ bByVal = bByVal_; }
|
2011-11-26 00:16:58 -05:00
|
|
|
void SetStatic( bool bAsStatic = true ) { bStatic = bAsStatic; }
|
2011-01-10 14:40:57 +01:00
|
|
|
void SetNew() { bNew = sal_True; }
|
|
|
|
void SetDefinedAs() { bAs = sal_True; }
|
2011-11-26 00:16:58 -05:00
|
|
|
void SetGlobal(bool b){ bGlobal = b; }
|
2011-01-10 14:40:57 +01:00
|
|
|
void SetDefaultId( sal_uInt16 n ) { nDefaultId = n; }
|
|
|
|
sal_uInt16 GetDefaultId( void ) { return nDefaultId; }
|
2011-11-26 00:16:58 -05:00
|
|
|
bool IsOptional() const{ return bOpt; }
|
|
|
|
bool IsParamArray() const{ return bParamArray; }
|
|
|
|
bool IsWithEvents() const{ return bWithEvents; }
|
|
|
|
bool IsWithBrackets() const{ return bWithBrackets; }
|
|
|
|
bool IsByVal() const { return bByVal; }
|
|
|
|
bool IsStatic() const { return bStatic; }
|
|
|
|
bool IsNew() const { return bNew; }
|
|
|
|
bool IsDefinedAs() const { return bAs; }
|
|
|
|
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-08-27 21:37:14 +02:00
|
|
|
sal_uInt32 Define(); // define symbol in code
|
|
|
|
sal_uInt32 Reference(); // reference symbol in code
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SbiSymDef( const SbiSymDef& );
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
class SbiProcDef : public SbiSymDef { // procedure definition (from basic):
|
|
|
|
SbiSymPool aParams;
|
|
|
|
SbiSymPool aLabels; // local jump targets
|
|
|
|
String aLibName;
|
|
|
|
String aAlias;
|
|
|
|
sal_uInt16 nLine1, nLine2; // line area
|
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-08-27 21:37:14 +02:00
|
|
|
sal_Bool bCdecl : 1; // sal_True: CDECL given
|
|
|
|
sal_Bool bPublic : 1; // sal_True: proc is PUBLIC
|
2011-01-10 14:40:57 +01:00
|
|
|
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
|
|
|
|
2011-08-27 21:37:14 +02:00
|
|
|
// Match with a forward-declaration. The parameter names are
|
|
|
|
// compared and the forward declaration is replaced by this
|
2000-09-18 15:18:56 +00:00
|
|
|
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: */
|