LCOV - code coverage report
Current view: top level - basic/source/inc - symtbl.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 53 59 89.8 %
Date: 2015-06-13 12:38:46 Functions: 53 59 89.8 %
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             : #include <boost/ptr_container/ptr_vector.hpp>
      25             : 
      26             : class SbiConstDef;
      27             : class SbiParser;
      28             : class SbiProcDef;
      29             : class SbiStringPool;
      30             : class SbiSymDef;                    // base class
      31             : 
      32             : enum SbiSymScope { SbLOCAL, SbPARAM, SbPUBLIC, SbGLOBAL, SbRTL };
      33             : 
      34             : // The string-pool collects string entries and
      35             : // makes sure that they don't exist twice.
      36             : 
      37             : class SbiStringPool {
      38             :     const OUString aEmpty;
      39             :     std::vector<OUString> aData;
      40             :     SbiParser* pParser;
      41             : public:
      42             :     SbiStringPool( SbiParser* );
      43             :    ~SbiStringPool();
      44         185 :     sal_uInt32 GetSize() const { return aData.size(); }
      45             :     // From 8.4.1999: default changed to true because of #64236 -
      46             :     // change it back to false when the bug is cleanly removed.
      47             :     short Add( const OUString&, bool=true );
      48             :     short Add( double, SbxDataType );
      49             :     const OUString& Find( sal_uInt32 ) const;
      50        4438 :     SbiParser* GetParser() { return pParser; }
      51             : };
      52             : 
      53             : 
      54             : typedef boost::ptr_vector<SbiSymDef> SbiSymbols;
      55             : 
      56             : class SbiSymPool {
      57             :     friend class SbiSymDef;
      58             :     friend class SbiProcDef;
      59             : protected:
      60             :     SbiStringPool& rStrings;
      61             :     SbiSymbols  aData;
      62             :     SbiSymPool* pParent;
      63             :     SbiParser*  pParser;
      64             :     SbiSymScope eScope;
      65             :     sal_uInt16     nProcId;             // for STATIC-variable
      66             :     sal_uInt16     nCur;                // iterator
      67             : public:
      68             :     SbiSymPool( SbiStringPool&, SbiSymScope );
      69             :    ~SbiSymPool();
      70             : 
      71        3530 :     void   SetParent( SbiSymPool* p )   { pParent = p;      }
      72         830 :     void   SetProcId( short n )         { nProcId = n;      }
      73        1101 :     sal_uInt16 GetSize() const              { return aData.size(); }
      74       23166 :     SbiSymScope GetScope() const        { return eScope;    }
      75        2948 :     void   SetScope( SbiSymScope s )    { eScope = s;       }
      76         284 :     SbiParser* GetParser()              { return pParser;   }
      77             : 
      78             :     SbiSymDef* AddSym( const OUString& );
      79             :     SbiProcDef* AddProc( const OUString& );
      80             :     void Add( SbiSymDef* );
      81             :     SbiSymDef* Find( const OUString& ); // variable name
      82             :     SbiSymDef* Get( sal_uInt16 );     // find variable per position
      83             :     SbiSymDef* First(), *Next();            // iterators
      84             : 
      85             :     sal_uInt32 Define( const OUString& );
      86             :     sal_uInt32 Reference( const OUString& );
      87             :     void   CheckRefs();
      88             : };
      89             : 
      90             : 
      91             : class SbiSymDef {                   // general symbol entry
      92             :     friend class SbiSymPool;
      93             : protected:
      94             :     OUString     aName;
      95             :     SbxDataType eType;
      96             :     SbiSymPool* pIn;                // parent pool
      97             :     SbiSymPool* pPool;              // pool for sub-elements
      98             :     short      nLen;                // string length for STRING*n
      99             :     short      nDims;
     100             :     sal_uInt16     nId;
     101             :     sal_uInt16     nTypeId;             // Dim X AS data type
     102             :     sal_uInt16     nProcId;
     103             :     sal_uInt16     nPos;
     104             :     sal_uInt32     nChain;
     105             :     bool       bNew     : 1;        // true: Dim As New...
     106             :     bool       bChained : 1;        // true: symbol is defined in code
     107             :     bool       bByVal   : 1;        // true: ByVal-parameter
     108             :     bool       bOpt     : 1;        // true: optional parameter
     109             :     bool       bStatic  : 1;        // true: STATIC variable
     110             :     bool       bAs      : 1;        // true: data type defined per AS XXX
     111             :     bool       bGlobal  : 1;        // true: global variable
     112             :     bool       bParamArray : 1;     // true: ParamArray parameter
     113             :     bool       bWithEvents : 1;     // true: Declared WithEvents
     114             :     bool       bWithBrackets : 1;   // true: Followed by ()
     115             :     sal_uInt16     nDefaultId;          // Symbol number of default value
     116             :     short      nFixedStringLength;  // String length in: Dim foo As String*Length
     117             : public:
     118             :     SbiSymDef( const OUString& );
     119             :     virtual ~SbiSymDef();
     120             :     virtual SbiProcDef* GetProcDef();
     121             :     virtual SbiConstDef* GetConstDef();
     122             : 
     123       30264 :     SbxDataType GetType() const { return eType;     }
     124             :     virtual void SetType( SbxDataType );
     125             :     const OUString& GetName();
     126             :     SbiSymScope GetScope() const;
     127             :     sal_uInt16 GetProcId() const{ return nProcId;   }
     128         419 :     sal_uInt32 GetAddr() const  { return nChain;    }
     129       13510 :     sal_uInt16 GetId() const    { return nId;       }
     130         727 :     sal_uInt16 GetTypeId() const{ return nTypeId;   }
     131         139 :     void       SetTypeId( sal_uInt16 n ) { nTypeId = n; eType = SbxOBJECT; }
     132        1418 :     sal_uInt16 GetPos() const   { return nPos;      }
     133        1029 :     void       SetLen( short n ){ nLen = n;         }
     134           0 :     short      GetLen() const   { return nLen;      }
     135          45 :     void       SetDims( short n ) { nDims = n;      }
     136        9087 :     short      GetDims() const  { return nDims;     }
     137         596 :     bool       IsDefined() const{ return bChained;  }
     138          46 :     void       SetOptional()    { bOpt = true;      }
     139           0 :     void       SetParamArray()  { bParamArray = true;       }
     140           0 :     void       SetWithEvents()  { bWithEvents = true;       }
     141          19 :     void       SetWithBrackets(){ bWithBrackets = true;     }
     142           4 :     void       SetByVal( bool bByVal_ = true ) { bByVal = bByVal_; }
     143         415 :     void       SetStatic( bool bAsStatic = true )      { bStatic = bAsStatic;  }
     144          28 :     void       SetNew()         { bNew = true;      }
     145        1029 :     void       SetDefinedAs()   { bAs = true;       }
     146          43 :     void       SetGlobal(bool b){ bGlobal = b;  }
     147           0 :     void       SetDefaultId( sal_uInt16 n ) { nDefaultId = n; }
     148         220 :     sal_uInt16 GetDefaultId() { return nDefaultId; }
     149         243 :     bool       IsOptional() const{ return bOpt;     }
     150         220 :     bool       IsParamArray() const{ return bParamArray; }
     151         851 :     bool       IsWithEvents() const{ return bWithEvents; }
     152         220 :     bool       IsWithBrackets() const{ return bWithBrackets; }
     153         224 :     bool       IsByVal() const  { return bByVal;    }
     154       13804 :     bool       IsStatic() const { return bStatic;   }
     155        1761 :     bool       IsNew() const    { return bNew;      }
     156        8758 :     bool       IsDefinedAs() const { return bAs;    }
     157        8036 :     bool       IsGlobal() const { return bGlobal;   }
     158         851 :     short      GetFixedStringLength() const { return nFixedStringLength; }
     159           0 :     void       SetFixedStringLength( short n ) { nFixedStringLength = n; }
     160             : 
     161             :     SbiSymPool& GetPool();
     162             :     sal_uInt32     Define();        // define symbol in code
     163             :     sal_uInt32     Reference();     // reference symbol in code
     164             : 
     165             : private:
     166             :     SbiSymDef( const SbiSymDef& ) SAL_DELETED_FUNCTION;
     167             : 
     168             : };
     169             : 
     170             : class SbiProcDef : public SbiSymDef {   // procedure definition (from basic):
     171             :     SbiSymPool aParams;
     172             :     SbiSymPool aLabels;             // local jump targets
     173             :     OUString aLibName;
     174             :     OUString aAlias;
     175             :     sal_uInt16 nLine1, nLine2;      // line area
     176             :     PropertyMode mePropMode;        // Marks if this is a property procedure and which
     177             :     OUString maPropName;              // Property name if property procedure (!= proc name)
     178             :     bool   bCdecl  : 1;             // true: CDECL given
     179             :     bool   bPublic : 1;             // true: proc is PUBLIC
     180             :     bool   mbProcDecl : 1;          // true: instantiated by SbiParser::ProcDecl
     181             : public:
     182             :     SbiProcDef( SbiParser*, const OUString&, bool bProcDecl=false );
     183             :     virtual ~SbiProcDef();
     184             :     virtual SbiProcDef* GetProcDef() SAL_OVERRIDE;
     185             :     virtual void SetType( SbxDataType ) SAL_OVERRIDE;
     186        1986 :     SbiSymPool& GetParams()         { return aParams;  }
     187         525 :     SbiSymPool& GetLabels()         { return aLabels;  }
     188         830 :     SbiSymPool& GetLocals()         { return GetPool();}
     189        1269 :     OUString& GetLib()              { return aLibName; }
     190         834 :     OUString& GetAlias()            { return aAlias;   }
     191         419 :     void SetPublic( bool b )        { bPublic = b;     }
     192         419 :     bool IsPublic() const           { return bPublic;  }
     193         415 :     void SetCdecl( bool b = true)   { bCdecl = b;      }
     194         419 :     bool IsCdecl() const            { return bCdecl;   }
     195         217 :     bool IsUsedForProcDecl() const  { return mbProcDecl; }
     196         419 :     void SetLine1( sal_uInt16 n )   { nLine1 = n;      }
     197         419 :     sal_uInt16 GetLine1() const     { return nLine1;   }
     198         419 :     void SetLine2( sal_uInt16 n )   { nLine2 = n;      }
     199         419 :     sal_uInt16 GetLine2() const     { return nLine2;   }
     200         419 :     PropertyMode getPropertyMode()  { return mePropMode; }
     201             :     void setPropertyMode( PropertyMode ePropMode );
     202           0 :     const OUString& GetPropName()     { return maPropName; }
     203             : 
     204             :     // Match with a forward-declaration. The parameter names are
     205             :     // compared and the forward declaration is replaced by this
     206             :     void Match( SbiProcDef* pForward );
     207             : 
     208             : private:
     209             :     SbiProcDef( const SbiProcDef& ) SAL_DELETED_FUNCTION;
     210             : 
     211             : };
     212             : 
     213             : class SbiConstDef : public SbiSymDef
     214             : {
     215             :     double nVal;
     216             :     OUString aVal;
     217             : public:
     218             :     SbiConstDef( const OUString& );
     219             :     virtual ~SbiConstDef();
     220             :     virtual SbiConstDef* GetConstDef() SAL_OVERRIDE;
     221             :     void Set( double, SbxDataType );
     222             :     void Set( const OUString& );
     223         110 :     double GetValue()           { return nVal; }
     224         151 :     const OUString& GetString() { return aVal; }
     225             : };
     226             : 
     227             : 
     228             : #endif
     229             : 
     230             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11