bump product version to 4.1.6.2
[LibreOffice.git] / basic / source / inc / symtbl.hxx
blobfa7309e0467c14ad154311e657aca41f950bc3b0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _SYMTBL_HXX
21 #define _SYMTBL_HXX
23 #include <vector>
25 class SbiConstDef;
26 class SbiParser;
27 class SbiProcDef;
28 class SbiStringPool;
29 class SbiSymDef; // base class
31 enum SbiSymScope { SbLOCAL, SbPARAM, SbPUBLIC, SbGLOBAL, SbRTL };
33 // The string-pool collects string entries and
34 // makes sure that they don't exist twice.
36 class SbiStringPool {
37 const OUString aEmpty;
38 std::vector<OUString> aData;
39 SbiParser* pParser;
40 public:
41 SbiStringPool( SbiParser* );
42 ~SbiStringPool();
43 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 SbiParser* GetParser() { return pParser; }
53 class SbiSymbols : public std::vector<SbiSymDef*>
55 public:
56 ~SbiSymbols();
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();
74 void SetParent( SbiSymPool* p ) { pParent = p; }
75 void SetProcId( short n ) { nProcId = n; }
76 sal_uInt16 GetSize() const { return aData.size(); }
77 SbiSymScope GetScope() const { return eScope; }
78 void SetScope( SbiSymScope s ) { eScope = s; }
79 SbiParser* GetParser() { return pParser; }
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
89 sal_uInt32 Define( const OUString& );
90 sal_uInt32 Reference( const OUString& );
91 void CheckRefs();
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();
127 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 sal_uInt32 GetAddr() const { return nChain; }
133 sal_uInt16 GetId() const { return nId; }
134 sal_uInt16 GetTypeId() const{ return nTypeId; }
135 void SetTypeId( sal_uInt16 n ) { nTypeId = n; eType = SbxOBJECT; }
136 sal_uInt16 GetPos() const { return nPos; }
137 void SetLen( short n ){ nLen = n; }
138 short GetLen() const { return nLen; }
139 void SetDims( short n ) { nDims = n; }
140 short GetDims() const { return nDims; }
141 bool IsDefined() const{ return bChained; }
142 void SetOptional() { bOpt = true; }
143 void SetParamArray() { bParamArray = true; }
144 void SetWithEvents() { bWithEvents = true; }
145 void SetWithBrackets(){ bWithBrackets = true; }
146 void SetByVal( bool bByVal_ = true ) { bByVal = bByVal_; }
147 void SetStatic( bool bAsStatic = true ) { bStatic = bAsStatic; }
148 void SetNew() { bNew = true; }
149 void SetDefinedAs() { bAs = true; }
150 void SetGlobal(bool b){ bGlobal = b; }
151 void SetDefaultId( sal_uInt16 n ) { nDefaultId = n; }
152 sal_uInt16 GetDefaultId( void ) { return nDefaultId; }
153 bool IsOptional() const{ return bOpt; }
154 bool IsParamArray() const{ return bParamArray; }
155 bool IsWithEvents() const{ return bWithEvents; }
156 bool IsWithBrackets() const{ return bWithBrackets; }
157 bool IsByVal() const { return bByVal; }
158 bool IsStatic() const { return bStatic; }
159 bool IsNew() const { return bNew; }
160 bool IsDefinedAs() const { return bAs; }
161 bool IsGlobal() const { return bGlobal; }
162 short GetFixedStringLength( void ) const { return nFixedStringLength; }
163 void SetFixedStringLength( short n ) { nFixedStringLength = n; }
165 SbiSymPool& GetPool();
166 sal_uInt32 Define(); // define symbol in code
167 sal_uInt32 Reference(); // reference symbol in code
169 private:
170 SbiSymDef( const SbiSymDef& );
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();
189 virtual void SetType( SbxDataType );
190 SbiSymPool& GetParams() { return aParams; }
191 SbiSymPool& GetLabels() { return aLabels; }
192 SbiSymPool& GetLocals() { return GetPool();}
193 OUString& GetLib() { return aLibName; }
194 OUString& GetAlias() { return aAlias; }
195 void SetPublic( bool b ) { bPublic = b; }
196 bool IsPublic() const { return bPublic; }
197 void SetCdecl( bool b = true) { bCdecl = b; }
198 bool IsCdecl() const { return bCdecl; }
199 bool IsUsedForProcDecl() const { return mbProcDecl; }
200 void SetLine1( sal_uInt16 n ) { nLine1 = n; }
201 sal_uInt16 GetLine1() const { return nLine1; }
202 void SetLine2( sal_uInt16 n ) { nLine2 = n; }
203 sal_uInt16 GetLine2() const { return nLine2; }
204 PropertyMode getPropertyMode() { return mePropMode; }
205 void setPropertyMode( PropertyMode ePropMode );
206 const OUString& GetPropName() { return maPropName; }
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 );
212 private:
213 SbiProcDef( const SbiProcDef& );
217 class SbiConstDef : public SbiSymDef
219 double nVal;
220 OUString aVal;
221 public:
222 SbiConstDef( const OUString& );
223 virtual ~SbiConstDef();
224 virtual SbiConstDef* GetConstDef();
225 void Set( double, SbxDataType );
226 void Set( const OUString& );
227 double GetValue() { return nVal; }
228 const OUString& GetString() { return aVal; }
232 #endif
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */