LCOV - code coverage report
Current view: top level - basic/source/inc - symtbl.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 60 0.0 %
Date: 2014-04-14 Functions: 0 60 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_BASIC_SOURCE_INC_SYMTBL_HXX
      21             : #define INCLUDED_BASIC_SOURCE_INC_SYMTBL_HXX
      22             : 
      23             : #include <vector>
      24             : 
      25             : class SbiConstDef;
      26             : class SbiParser;
      27             : class SbiProcDef;
      28             : class SbiStringPool;
      29             : class SbiSymDef;                    // base class
      30             : 
      31             : enum SbiSymScope { SbLOCAL, SbPARAM, SbPUBLIC, SbGLOBAL, SbRTL };
      32             : 
      33             : // The string-pool collects string entries and
      34             : // makes sure that they don't exist twice.
      35             : 
      36             : class SbiStringPool {
      37             :     const OUString aEmpty;
      38             :     std::vector<OUString> aData;
      39             :     SbiParser* pParser;
      40             : public:
      41             :     SbiStringPool( SbiParser* );
      42             :    ~SbiStringPool();
      43           0 :     sal_uInt32 GetSize() const { return aData.size(); }
      44             :     // From 8.4.1999: default changed to true because of #64236 -
      45             :     // change it back to false when the bug is cleanly removed.
      46             :     short Add( const OUString&, bool=true );
      47             :     short Add( double, SbxDataType );
      48             :     const OUString& Find( sal_uInt32 ) const;
      49           0 :     SbiParser* GetParser() { return pParser; }
      50             : };
      51             : 
      52             : 
      53           0 : class SbiSymbols : public std::vector<SbiSymDef*>
      54             : {
      55             : public:
      56             :     ~SbiSymbols();
      57             : };
      58             : 
      59             : class SbiSymPool {
      60             :     friend class SbiSymDef;
      61             :     friend class SbiProcDef;
      62             : protected:
      63             :     SbiStringPool& rStrings;
      64             :     SbiSymbols  aData;
      65             :     SbiSymPool* pParent;
      66             :     SbiParser*  pParser;
      67             :     SbiSymScope eScope;
      68             :     sal_uInt16     nProcId;             // for STATIC-variable
      69             :     sal_uInt16     nCur;                // iterator
      70             : public:
      71             :     SbiSymPool( SbiStringPool&, SbiSymScope );
      72             :    ~SbiSymPool();
      73             : 
      74           0 :     void   SetParent( SbiSymPool* p )   { pParent = p;      }
      75           0 :     void   SetProcId( short n )         { nProcId = n;      }
      76           0 :     sal_uInt16 GetSize() const              { return aData.size(); }
      77           0 :     SbiSymScope GetScope() const        { return eScope;    }
      78           0 :     void   SetScope( SbiSymScope s )    { eScope = s;       }
      79           0 :     SbiParser* GetParser()              { return pParser;   }
      80             : 
      81             :     SbiSymDef* AddSym( const OUString& );
      82             :     SbiProcDef* AddProc( const OUString& );
      83             :     void Add( SbiSymDef* );
      84             :     SbiSymDef* Find( const OUString& ) const; // variable name
      85             :     SbiSymDef* FindId( sal_uInt16 ) const;
      86             :     SbiSymDef* Get( sal_uInt16 ) const;     // find variable per position
      87             :     SbiSymDef* First(), *Next();            // iterators
      88             : 
      89             :     sal_uInt32 Define( const OUString& );
      90             :     sal_uInt32 Reference( const OUString& );
      91             :     void   CheckRefs();
      92             : };
      93             : 
      94             : 
      95             : class SbiSymDef {                   // general symbol entry
      96             :     friend class SbiSymPool;
      97             : protected:
      98             :     OUString     aName;
      99             :     SbxDataType eType;
     100             :     SbiSymPool* pIn;                // parent pool
     101             :     SbiSymPool* pPool;              // pool for sub-elements
     102             :     short      nLen;                // string length for STRING*n
     103             :     short      nDims;
     104             :     sal_uInt16     nId;
     105             :     sal_uInt16     nTypeId;             // Dim X AS data type
     106             :     sal_uInt16     nProcId;
     107             :     sal_uInt16     nPos;
     108             :     sal_uInt32     nChain;
     109             :     bool       bNew     : 1;        // true: Dim As New...
     110             :     bool       bChained : 1;        // true: symbol is defined in code
     111             :     bool       bByVal   : 1;        // true: ByVal-parameter
     112             :     bool       bOpt     : 1;        // true: optional parameter
     113             :     bool       bStatic  : 1;        // true: STATIC variable
     114             :     bool       bAs      : 1;        // true: data type defined per AS XXX
     115             :     bool       bGlobal  : 1;        // true: global variable
     116             :     bool       bParamArray : 1;     // true: ParamArray parameter
     117             :     bool       bWithEvents : 1;     // true: Declared WithEvents
     118             :     bool       bWithBrackets : 1;   // true: Followed by ()
     119             :     sal_uInt16     nDefaultId;          // Symbol number of default value
     120             :     short      nFixedStringLength;  // String length in: Dim foo As String*Length
     121             : public:
     122             :     SbiSymDef( const OUString& );
     123             :     virtual ~SbiSymDef();
     124             :     virtual SbiProcDef* GetProcDef();
     125             :     virtual SbiConstDef* GetConstDef();
     126             : 
     127           0 :     SbxDataType GetType() const { return eType;     }
     128             :     virtual void SetType( SbxDataType );
     129             :     const OUString& GetName();
     130             :     SbiSymScope GetScope() const;
     131             :     sal_uInt16 GetProcId() const{ return nProcId;   }
     132           0 :     sal_uInt32 GetAddr() const  { return nChain;    }
     133           0 :     sal_uInt16 GetId() const    { return nId;       }
     134           0 :     sal_uInt16 GetTypeId() const{ return nTypeId;   }
     135           0 :     void       SetTypeId( sal_uInt16 n ) { nTypeId = n; eType = SbxOBJECT; }
     136           0 :     sal_uInt16 GetPos() const   { return nPos;      }
     137           0 :     void       SetLen( short n ){ nLen = n;         }
     138           0 :     short      GetLen() const   { return nLen;      }
     139           0 :     void       SetDims( short n ) { nDims = n;      }
     140           0 :     short      GetDims() const  { return nDims;     }
     141           0 :     bool       IsDefined() const{ return bChained;  }
     142           0 :     void       SetOptional()    { bOpt = true;      }
     143           0 :     void       SetParamArray()  { bParamArray = true;       }
     144           0 :     void       SetWithEvents()  { bWithEvents = true;       }
     145           0 :     void       SetWithBrackets(){ bWithBrackets = true;     }
     146           0 :     void       SetByVal( bool bByVal_ = true ) { bByVal = bByVal_; }
     147           0 :     void       SetStatic( bool bAsStatic = true )      { bStatic = bAsStatic;  }
     148           0 :     void       SetNew()         { bNew = true;      }
     149           0 :     void       SetDefinedAs()   { bAs = true;       }
     150           0 :     void       SetGlobal(bool b){ bGlobal = b;  }
     151           0 :     void       SetDefaultId( sal_uInt16 n ) { nDefaultId = n; }
     152           0 :     sal_uInt16 GetDefaultId( void ) { return nDefaultId; }
     153           0 :     bool       IsOptional() const{ return bOpt;     }
     154           0 :     bool       IsParamArray() const{ return bParamArray; }
     155           0 :     bool       IsWithEvents() const{ return bWithEvents; }
     156           0 :     bool       IsWithBrackets() const{ return bWithBrackets; }
     157           0 :     bool       IsByVal() const  { return bByVal;    }
     158           0 :     bool       IsStatic() const { return bStatic;   }
     159           0 :     bool       IsNew() const    { return bNew;      }
     160           0 :     bool       IsDefinedAs() const { return bAs;    }
     161           0 :     bool       IsGlobal() const { return bGlobal;   }
     162           0 :     short      GetFixedStringLength( void ) const { return nFixedStringLength; }
     163           0 :     void       SetFixedStringLength( short n ) { nFixedStringLength = n; }
     164             : 
     165             :     SbiSymPool& GetPool();
     166             :     sal_uInt32     Define();        // define symbol in code
     167             :     sal_uInt32     Reference();     // reference symbol in code
     168             : 
     169             : private:
     170             :     SbiSymDef( const SbiSymDef& );
     171             : 
     172             : };
     173             : 
     174             : class SbiProcDef : public SbiSymDef {   // procedure definition (from basic):
     175             :     SbiSymPool aParams;
     176             :     SbiSymPool aLabels;             // local jump targets
     177             :     OUString aLibName;
     178             :     OUString aAlias;
     179             :     sal_uInt16 nLine1, nLine2;      // line area
     180             :     PropertyMode mePropMode;        // Marks if this is a property procedure and which
     181             :     OUString maPropName;              // Property name if property procedure (!= proc name)
     182             :     bool   bCdecl  : 1;             // true: CDECL given
     183             :     bool   bPublic : 1;             // true: proc is PUBLIC
     184             :     bool   mbProcDecl : 1;          // true: instanciated by SbiParser::ProcDecl
     185             : public:
     186             :     SbiProcDef( SbiParser*, const OUString&, bool bProcDecl=false );
     187             :     virtual ~SbiProcDef();
     188             :     virtual SbiProcDef* GetProcDef() SAL_OVERRIDE;
     189             :     virtual void SetType( SbxDataType ) SAL_OVERRIDE;
     190           0 :     SbiSymPool& GetParams()         { return aParams;  }
     191           0 :     SbiSymPool& GetLabels()         { return aLabels;  }
     192           0 :     SbiSymPool& GetLocals()         { return GetPool();}
     193           0 :     OUString& GetLib()              { return aLibName; }
     194           0 :     OUString& GetAlias()            { return aAlias;   }
     195           0 :     void SetPublic( bool b )        { bPublic = b;     }
     196           0 :     bool IsPublic() const           { return bPublic;  }
     197           0 :     void SetCdecl( bool b = true)   { bCdecl = b;      }
     198           0 :     bool IsCdecl() const            { return bCdecl;   }
     199           0 :     bool IsUsedForProcDecl() const  { return mbProcDecl; }
     200           0 :     void SetLine1( sal_uInt16 n )   { nLine1 = n;      }
     201           0 :     sal_uInt16 GetLine1() const     { return nLine1;   }
     202           0 :     void SetLine2( sal_uInt16 n )   { nLine2 = n;      }
     203           0 :     sal_uInt16 GetLine2() const     { return nLine2;   }
     204           0 :     PropertyMode getPropertyMode()  { return mePropMode; }
     205             :     void setPropertyMode( PropertyMode ePropMode );
     206           0 :     const OUString& GetPropName()     { return maPropName; }
     207             : 
     208             :     // Match with a forward-declaration. The parameter names are
     209             :     // compared and the forward declaration is replaced by this
     210             :     void Match( SbiProcDef* pForward );
     211             : 
     212             : private:
     213             :     SbiProcDef( const SbiProcDef& );
     214             : 
     215             : };
     216             : 
     217             : class SbiConstDef : public SbiSymDef
     218             : {
     219             :     double nVal;
     220             :     OUString aVal;
     221             : public:
     222             :     SbiConstDef( const OUString& );
     223             :     virtual ~SbiConstDef();
     224             :     virtual SbiConstDef* GetConstDef() SAL_OVERRIDE;
     225             :     void Set( double, SbxDataType );
     226             :     void Set( const OUString& );
     227           0 :     double GetValue()           { return nVal; }
     228           0 :     const OUString& GetString() { return aVal; }
     229             : };
     230             : 
     231             : 
     232             : #endif
     233             : 
     234             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10