LCOV - code coverage report
Current view: top level - basic/source/inc - symtbl.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 55 61 90.2 %
Date: 2012-08-25 Functions: 54 60 90.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     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 _SYMTBL_HXX
      21                 :            : #define _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 rtl::OUString aEmpty;
      38                 :            :     std::vector<rtl::OUString> aData;
      39                 :            :     SbiParser* pParser;
      40                 :            : public:
      41                 :            :     SbiStringPool( SbiParser* );
      42                 :            :    ~SbiStringPool();
      43                 :         65 :     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 rtl::OUString&, bool=true );
      47                 :            :     short Add( double, SbxDataType );
      48                 :            :     const rtl::OUString& Find( sal_uInt32 ) const;
      49                 :       2407 :     SbiParser* GetParser() { return pParser; }
      50                 :            : };
      51                 :            : 
      52                 :            : 
      53                 :       2407 : 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                 :       1818 :     void   SetParent( SbiSymPool* p )   { pParent = p;      }
      75                 :        394 :     void   SetProcId( short n )         { nProcId = n;      }
      76                 :        531 :     sal_uInt16 GetSize() const              { return aData.size(); }
      77                 :      11883 :     SbiSymScope GetScope() const        { return eScope;    }
      78                 :        816 :     void   SetScope( SbiSymScope s )    { eScope = s;       }
      79                 :        136 :     SbiParser* GetParser()              { return pParser;   }
      80                 :            : 
      81                 :            :     SbiSymDef* AddSym( const String& );
      82                 :            :     SbiProcDef* AddProc( const String& );
      83                 :            :     void Add( SbiSymDef* );
      84                 :            :     SbiSymDef* Find( const String& ) 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 String& );
      90                 :            :     sal_uInt32 Reference( const String& );
      91                 :            :     void   CheckRefs();
      92                 :            : };
      93                 :            : 
      94                 :            : 
      95                 :            : class SbiSymDef {                   // general symbol entry
      96                 :            :     friend class SbiSymPool;
      97                 :            : protected:
      98                 :            :     String     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 String& );
     123                 :            :     virtual ~SbiSymDef();
     124                 :            :     virtual SbiProcDef* GetProcDef();
     125                 :            :     virtual SbiConstDef* GetConstDef();
     126                 :            : 
     127                 :      13940 :     SbxDataType GetType() const { return eType;     }
     128                 :            :     virtual void SetType( SbxDataType );
     129                 :            :     const String& GetName();
     130                 :            :     SbiSymScope GetScope() const;
     131                 :            :     sal_uInt16     GetProcId() const{ return nProcId;   }
     132                 :        197 :     sal_uInt32     GetAddr() const  { return nChain;    }
     133                 :       5989 :     sal_uInt16     GetId() const    { return nId;       }
     134                 :        282 :     sal_uInt16     GetTypeId() const{ return nTypeId;   }
     135                 :         46 :     void       SetTypeId( sal_uInt16 n ) { nTypeId = n; eType = SbxOBJECT; }
     136                 :        852 :     sal_uInt16     GetPos() const   { return nPos;      }
     137                 :        448 :     void       SetLen( short n ){ nLen = n;         }
     138                 :          0 :     short      GetLen() const   { return nLen;      }
     139                 :         48 :     void       SetDims( short n ) { nDims = n;      }
     140                 :       4397 :     short      GetDims() const  { return nDims;     }
     141                 :        291 :     bool       IsDefined() const{ return bChained;  }
     142                 :          2 :     void       SetOptional()    { bOpt = true;      }
     143                 :          0 :     void       SetParamArray()  { bParamArray = true;       }
     144                 :          0 :     void       SetWithEvents()  { bWithEvents = true;       }
     145                 :         10 :     void       SetWithBrackets(){ bWithBrackets = true;     }
     146                 :          6 :     void       SetByVal( bool bByVal_ = true )
     147                 :          6 :                 { bByVal = bByVal_; }
     148                 :        197 :     void       SetStatic( bool bAsStatic = true )      { bStatic = bAsStatic;  }
     149                 :         40 :     void       SetNew()         { bNew = true;      }
     150                 :        448 :     void       SetDefinedAs()   { bAs = true;       }
     151                 :         44 :     void       SetGlobal(bool b){ bGlobal = b;  }
     152                 :          0 :     void       SetDefaultId( sal_uInt16 n ) { nDefaultId = n; }
     153                 :        128 :     sal_uInt16     GetDefaultId( void ) { return nDefaultId; }
     154                 :        130 :     bool       IsOptional() const{ return bOpt;     }
     155                 :        128 :     bool       IsParamArray() const{ return bParamArray; }
     156                 :        498 :     bool       IsWithEvents() const{ return bWithEvents; }
     157                 :        128 :     bool       IsWithBrackets() const{ return bWithBrackets; }
     158                 :        128 :     bool       IsByVal() const  { return bByVal;    }
     159                 :       6209 :     bool       IsStatic() const { return bStatic;   }
     160                 :        516 :     bool       IsNew() const    { return bNew;      }
     161                 :       4057 :     bool       IsDefinedAs() const { return bAs;    }
     162                 :       3930 :     bool       IsGlobal() const { return bGlobal;   }
     163                 :        498 :     short      GetFixedStringLength( void ) const { return nFixedStringLength; }
     164                 :          0 :     void       SetFixedStringLength( short n ) { nFixedStringLength = n; }
     165                 :            : 
     166                 :            :     SbiSymPool& GetPool();
     167                 :            :     sal_uInt32     Define();        // define symbol in code
     168                 :            :     sal_uInt32     Reference();     // reference symbol in code
     169                 :            : 
     170                 :            : private:
     171                 :            :     SbiSymDef( const SbiSymDef& );
     172                 :            : 
     173                 :            : };
     174                 :            : 
     175                 :            : class SbiProcDef : public SbiSymDef {   // procedure definition (from basic):
     176                 :            :     SbiSymPool aParams;
     177                 :            :     SbiSymPool aLabels;             // local jump targets
     178                 :            :     String aLibName;
     179                 :            :     String aAlias;
     180                 :            :     sal_uInt16 nLine1, nLine2;      // line area
     181                 :            :     PropertyMode mePropMode;        // Marks if this is a property procedure and which
     182                 :            :     String maPropName;              // Property name if property procedure (!= proc name)
     183                 :            :     bool   bCdecl  : 1;             // true: CDECL given
     184                 :            :     bool   bPublic : 1;             // true: proc is PUBLIC
     185                 :            :     bool   mbProcDecl : 1;          // true: instanciated by SbiParser::ProcDecl
     186                 :            : public:
     187                 :            :     SbiProcDef( SbiParser*, const String&, bool bProcDecl=false );
     188                 :            :     virtual ~SbiProcDef();
     189                 :            :     virtual SbiProcDef* GetProcDef();
     190                 :            :     virtual void SetType( SbxDataType );
     191                 :       1162 :     SbiSymPool& GetParams()         { return aParams;  }
     192                 :        229 :     SbiSymPool& GetLabels()         { return aLabels;  }
     193                 :        394 :     SbiSymPool& GetLocals()         { return GetPool();}
     194                 :        591 :     String& GetLib()                { return aLibName; }
     195                 :        394 :     String& GetAlias()              { return aAlias;   }
     196                 :        197 :     void SetPublic( bool b )        { bPublic = b;     }
     197                 :        197 :     bool IsPublic() const           { return bPublic;  }
     198                 :        197 :     void SetCdecl( bool b = true)   { bCdecl = b;      }
     199                 :        197 :     bool IsCdecl() const            { return bCdecl;   }
     200                 :         74 :     bool IsUsedForProcDecl() const  { return mbProcDecl; }
     201                 :        197 :     void SetLine1( sal_uInt16 n )       { nLine1 = n;      }
     202                 :        197 :     sal_uInt16 GetLine1() const         { return nLine1;   }
     203                 :        197 :     void SetLine2( sal_uInt16 n )       { nLine2 = n;      }
     204                 :        197 :     sal_uInt16 GetLine2() const         { return nLine2;   }
     205                 :        197 :     PropertyMode getPropertyMode()  { return mePropMode; }
     206                 :            :     void setPropertyMode( PropertyMode ePropMode );
     207                 :          0 :     const String& GetPropName()     { return maPropName; }
     208                 :            : 
     209                 :            :     // Match with a forward-declaration. The parameter names are
     210                 :            :     // compared and the forward declaration is replaced by this
     211                 :            :     void Match( SbiProcDef* pForward );
     212                 :            : 
     213                 :            : private:
     214                 :            :     SbiProcDef( const SbiProcDef& );
     215                 :            : 
     216                 :            : };
     217                 :            : 
     218                 :            : class SbiConstDef : public SbiSymDef
     219                 :            : {
     220                 :            :     double nVal;
     221                 :            :     String aVal;
     222                 :            : public:
     223                 :            :     SbiConstDef( const String& );
     224                 :            :     virtual ~SbiConstDef();
     225                 :            :     virtual SbiConstDef* GetConstDef();
     226                 :            :     void Set( double, SbxDataType );
     227                 :            :     void Set( const String& );
     228                 :        228 :     double GetValue()           { return nVal; }
     229                 :        340 :     const String& GetString()   { return aVal; }
     230                 :            : };
     231                 :            : 
     232                 :            : 
     233                 :            : #endif
     234                 :            : 
     235                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10