source: dev/trunk/ab5.0/abdev/ab_common/include/Lexical/Procedure.h@ 604

Last change on this file since 604 was 604, checked in by dai_9181, 16 years ago

不要なクラスのプロトタイプ宣言を排除。

File size: 11.5 KB
RevLine 
[184]1#pragma once
2
[208]3class Procedure : public Symbol
[184]4{
5public:
[206]6 // 種類
7 enum Kind{
8 Sub,
9 Function,
10 };
11
12private:
13 Kind kind;
14
15 bool isCdecl;
16 mutable bool isUsing;
17
18 // パラメータ
19 Parameters params;
20
[572]21protected:
22
[206]23 // 戻り値の型
24 Type returnType;
25
26 // ソースコードの位置
27 int codePos;
28
29 // XMLシリアライズ用
30private:
31 friend class boost::serialization::access;
[208]32 template<class Archive> void serialize(Archive& ar, const unsigned int version)
[184]33 {
[206]34 trace_for_serialize( "serializing - Procedure" );
35
[208]36 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
[206]37 ar & BOOST_SERIALIZATION_NVP( kind );
38 ar & BOOST_SERIALIZATION_NVP( isCdecl );
39 ar & BOOST_SERIALIZATION_NVP( isUsing );
40 ar & BOOST_SERIALIZATION_NVP( params );
41 ar & BOOST_SERIALIZATION_NVP( returnType );
42 ar & BOOST_SERIALIZATION_NVP( codePos );
[184]43 }
[206]44
45public:
[523]46 Procedure( const NamespaceScopes &namespaceScopes, const std::string &name, Kind kind, bool isCdecl )
[208]47 : Symbol( namespaceScopes, name )
[206]48 , kind( kind )
49 , isCdecl( isCdecl )
50 , isUsing( false )
51 , codePos( -1 )
52 {
53 }
54 Procedure()
55 {
56 }
57 ~Procedure(){
58 BOOST_FOREACH( Parameter *pParam, params ){
59 delete pParam;
60 }
61 }
62
63 bool IsSub() const
64 {
65 return ( kind == Sub );
66 }
67 bool IsFunction() const
68 {
69 return ( kind == Function );
70 }
71
72 bool IsCdecl() const
73 {
74 return isCdecl;
75 }
76 void Using() const
77 {
78 isUsing = true;
79 }
80 bool IsUsing() const
81 {
82 return isUsing;
83 }
84
85 int GetCodePos() const
86 {
87 return codePos;
88 }
[572]89 void SetCodePos( int codePos )
90 {
91 this->codePos = codePos;
92 }
[206]93
94 const Parameters &Params() const
95 {
96 return params;
97 }
[572]98 Parameters &GetParameters()
99 {
100 return params;
101 }
[206]102 const Type &ReturnType() const
103 {
104 return returnType;
105 }
[572]106 Type &ReturnType()
107 {
108 return returnType;
109 }
[184]110};
111
[206]112class UserProc : public Procedure, public Jenga::Common::ObjectInHashmap<UserProc>
[184]113{
114public:
[523]115 std::string _paramStr;
[184]116
[206]117private:
118 NamespaceScopesCollection importedNamespaces;
[184]119
[206]120 // 親クラスと対応するメソッド
121 const CClass *pParentClass;
[353]122 const Interface *pInterface;
[206]123 CMethod *pMethod;
124
125 bool isMacro;
126
127 // パラメータの追加情報
128 int secondParmNum;
129 Parameters realParams;
130 int realSecondParmNum;
131
132 // 各種フラグ
133 bool isExport;
134 mutable bool isSystem;
135 mutable bool isAutoGeneration;
136 mutable bool isCompiled;
137
138 mutable DWORD beginOpAddress;
139 mutable DWORD endOpAddress;
140
141 // ローカル変数
142 mutable Variables localVars;
143
144 // 識別ID
145 int id;
146
[224]147 // ネイティブコード
148 NativeCode nativeCode;
149
[206]150 // XMLシリアライズ用
151private:
152 friend class boost::serialization::access;
153 template<class Archive> void serialize(Archive& ar, const unsigned int version)
[184]154 {
[206]155 trace_for_serialize( "serializing - UserProc" );
156
157 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Procedure );
158 ar & BOOST_SERIALIZATION_NVP( _paramStr );
159 ar & BOOST_SERIALIZATION_NVP( importedNamespaces );
160 ar & boost::serialization::make_nvp("pParentClass", const_cast<CClass *&>(pParentClass) );
[353]161 ar & boost::serialization::make_nvp("pInterface", const_cast<Interface *&>(pInterface) );
[206]162 ar & BOOST_SERIALIZATION_NVP( pMethod );
163 ar & BOOST_SERIALIZATION_NVP( isMacro );
164 ar & BOOST_SERIALIZATION_NVP( secondParmNum );
165 ar & BOOST_SERIALIZATION_NVP( realParams );
166 ar & BOOST_SERIALIZATION_NVP( realSecondParmNum );
167 ar & BOOST_SERIALIZATION_NVP( isExport );
168 ar & BOOST_SERIALIZATION_NVP( isSystem );
169 ar & BOOST_SERIALIZATION_NVP( isAutoGeneration );
170 ar & BOOST_SERIALIZATION_NVP( isCompiled );
171 ar & BOOST_SERIALIZATION_NVP( beginOpAddress );
172 ar & BOOST_SERIALIZATION_NVP( endOpAddress );
173 ar & BOOST_SERIALIZATION_NVP( localVars );
174 ar & BOOST_SERIALIZATION_NVP( id );
[224]175 ar & BOOST_SERIALIZATION_NVP( nativeCode );
[184]176 }
177
[206]178public:
179
[523]180 UserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const std::string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport )
[208]181 : Procedure( namespaceScopes, name, kind, isCdecl )
[206]182 , importedNamespaces( importedNamespaces )
183 , pParentClass( NULL )
[353]184 , pInterface( NULL )
[206]185 , pMethod( NULL )
186 , isMacro( isMacro )
[511]187 , secondParmNum( 0 )
188 , realSecondParmNum( 1 )
[206]189 , isExport( isExport )
190 , isSystem( false )
191 , isAutoGeneration( false )
192 , isCompiled( false )
193 , beginOpAddress( 0 )
194 , endOpAddress( 0 )
195 {
[511]196 static int id_base=0;
197 id = ( id_base ++ );
[206]198 }
199 UserProc()
200 {
201 }
202 ~UserProc()
203 {
204 BOOST_FOREACH( Parameter *pParam, realParams ){
205 delete pParam;
206 }
207 }
208
[511]209 void SetReturnType( const Type &newReturnType )
210 {
211 returnType = newReturnType;
212 }
213
[206]214 virtual const std::string &GetKeyName() const
215 {
216 return GetName();
217 }
218
[209]219 virtual bool IsDuplication( const UserProc *pUserProc ) const
220 {
[326]221 if( this->GetParentClassPtr() == pUserProc->GetParentClassPtr() // 親クラスが等しい
[353]222 && this->pInterface == pUserProc->pInterface // インターフェイスが等しい
[326]223 && pUserProc->IsEqualSymbol( *this ) // 名前空間及び名前が等しい
224 && this->Params().Equals( pUserProc->Params() ) // パラメータが等しい
225 && this->returnType.Equals( pUserProc->returnType ) ) // 戻り値が等しい
[209]226 {
227 return true;
228 }
229 return false;
230 }
231
[382]232 /*!
233 @brief オーバーライド用に関数同士が等しいかどうかをチェックする
234 @param actualTypeParametersForThisProc thisオブジェクトで保有するメソッドを対象とした実型パラメータ
235 pUserProc 照らし合わせる関数
236 */
237 bool IsEqualForOverride( const Types &actualTypeParametersForThisProc, const UserProc *pUserProc ) const;
[351]238
[206]239 bool IsMacro() const
240 {
241 return isMacro;
242 }
243
244 int GetSecondParmNum() const
245 {
246 return secondParmNum;
247 }
[572]248 void SetSecondParmNum( int secondParmNum )
249 {
250 this->secondParmNum = secondParmNum;
251 }
[206]252 const Parameters &RealParams() const
253 {
254 return realParams;
255 }
[572]256 Parameters &RealParams()
257 {
258 return realParams;
259 }
[511]260 void SetRealParams( const Parameters &params )
261 {
262 realParams = params;
263 }
[206]264 int GetRealSecondParmNum() const
265 {
266 return realSecondParmNum;
267 }
268
269 void ExportOff(){
270 isExport = false;
271 }
272 bool IsExport() const
273 {
274 return isExport;
275 }
276 void ThisIsSystemProc() const
277 {
278 isSystem = true;
279 }
280 bool IsSystem() const
281 {
282 return isSystem;
283 }
284 void ThisIsAutoGenerationProc() const
285 {
286 isAutoGeneration = true;
287 }
288 bool IsAutoGeneration() const
289 {
290 return isAutoGeneration;
291 }
292 void CompleteCompile() const
293 {
294 isCompiled = true;
295 }
296 void KillCompileStatus() const
297 {
298 isCompiled = false;
299 }
300 bool IsCompiled() const
301 {
302 return isCompiled;
303 }
304 bool IsDestructor() const
305 {
306 return ( GetName()[0] == '~' );
307 }
308
309 // バイナリコード位置とサイズ
310 DWORD GetBeginOpAddress() const
311 {
312 return beginOpAddress;
313 }
314 void SetBeginOpAddress( DWORD beginOpAddress ) const
315 {
316 this->beginOpAddress = beginOpAddress;
317 }
318 DWORD GetEndOpAddress() const
319 {
320 return endOpAddress;
321 }
322 void SetEndOpAddress( DWORD endOpAddress ) const
323 {
324 this->endOpAddress = endOpAddress;
325 }
326 int GetCodeSize() const
327 {
328 return endOpAddress - beginOpAddress;
329 }
330
[208]331 virtual const NamespaceScopes &GetNamespaceScopes() const;
[206]332 const NamespaceScopesCollection &GetImportedNamespaces() const;
333
334 Variables &GetLocalVars() const
335 {
336 return localVars;
337 }
338
339 int GetId() const
340 {
341 return id;
342 }
343
[257]344 const NativeCode &GetNativeCode() const
345 {
346 return nativeCode;
347 }
[225]348 NativeCode &GetNativeCode()
349 {
350 return nativeCode;
351 }
352
[206]353 std::string GetFullName() const;
[350]354 bool IsCastOperator() const;
[206]355
356 bool IsVirtual() const;
357
358 void SetParentClass( const CClass *pParentClass ){
359 this->pParentClass = pParentClass;
360 }
361 const CClass *GetParentClassPtr() const
362 {
363 return pParentClass;
364 }
365 const CClass &GetParentClass() const
366 {
367 return *pParentClass;
368 }
369 bool HasParentClass() const
370 {
371 return ( pParentClass != NULL );
372 }
[208]373 bool IsGlobalProcedure() const
374 {
375 return ( pParentClass == NULL );
376 }
[353]377 void SetInterface( const Interface *pInterface )
378 {
379 this->pInterface = pInterface;
380 }
[206]381 void SetMethod( CMethod *pMethod ){
382 this->pMethod = pMethod;
383 }
[336]384 const CMethod &GetMethod() const;
[206]385
386
[364]387 static const UserProc *pGlobalProc;
[184]388};
389
[206]390class UserProcs : public Jenga::Common::Hashmap<UserProc>
[184]391{
[206]392 // XMLシリアライズ用
393private:
394 friend class boost::serialization::access;
395 template<class Archive> void serialize(Archive& ar, const unsigned int version)
396 {
397 trace_for_serialize( "serializing - UserProcs" );
398
399 ar & boost::serialization::make_nvp("Hashmap_UserProcImpl",
400 boost::serialization::base_object<Jenga::Common::Hashmap<UserProc>>(*this));
401 }
402
403
[184]404public:
[206]405 UserProcs()
[184]406 {
407 }
[206]408 ~UserProcs()
409 {
410 }
[184]411
[576]412 void EnumGlobalProcs( const char *simpleName, const Symbol &localSymbol, std::vector<const UserProc *> &subs );
[206]413};
414
[209]415class DllProc : public Procedure, public Jenga::Common::ObjectInHashmap<DllProc>
[206]416{
[523]417 std::string dllFileName;
418 std::string alias;
[206]419 int lookupAddress;
420
421 // XMLシリアライズ用
422private:
423 friend class boost::serialization::access;
424 template<class Archive> void serialize(Archive& ar, const unsigned int version)
425 {
426 trace_for_serialize( "serializing - DllProc" );
427
428 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Procedure );
429 ar & BOOST_SERIALIZATION_NVP( dllFileName );
430 ar & BOOST_SERIALIZATION_NVP( alias );
431 ar & BOOST_SERIALIZATION_NVP( lookupAddress );
432 }
433
434public:
[523]435 DllProc( const NamespaceScopes &namespaceScopes, const std::string &name, Kind kind, bool isCdecl, const std::string &dllFileName, const std::string &alias )
[210]436 : Procedure( namespaceScopes, name, kind, isCdecl )
437 , dllFileName( dllFileName )
438 , alias( alias )
439 , lookupAddress( 0 )
[206]440 {
441 }
[210]442 DllProc()
443 {
444 }
[209]445 ~DllProc()
446 {
447 }
[206]448
[209]449 virtual const std::string &GetKeyName() const
450 {
451 return GetName();
452 }
453
454 virtual bool IsDuplication( const DllProc *pDllProc ) const
455 {
456 if( pDllProc->IsEqualSymbol( *this )
457 && this->Params().Equals( pDllProc->Params() ) )
458 {
459 return true;
460 }
461 return false;
462 }
463
[523]464 const std::string &GetDllFileName() const
[206]465 {
466 return dllFileName;
467 }
[523]468 const std::string &GetAlias() const
[206]469 {
470 return alias;
471 }
472
473 void SetLookupAddress( int lookupAddress ){
474 this->lookupAddress = lookupAddress;
475 }
476 int GetLookupAddress() const
477 {
478 return lookupAddress;
479 }
[184]480};
[209]481class DllProcs : public Jenga::Common::Hashmap<DllProc>
482{
483 // XMLシリアライズ用
484private:
485 friend class boost::serialization::access;
486 template<class Archive> void serialize(Archive& ar, const unsigned int version)
487 {
488 trace_for_serialize( "serializing - DllProcs" );
[184]489
[209]490 ar & boost::serialization::make_nvp("Hashmap_DllProc",
491 boost::serialization::base_object<Jenga::Common::Hashmap<DllProc>>(*this));
492 }
493};
494
[206]495class ProcPointer : public Procedure
[184]496{
[206]497 // XMLシリアライズ用
498private:
499 friend class boost::serialization::access;
500 template<class Archive> void serialize(Archive& ar, const unsigned int version)
501 {
502 trace_for_serialize( "serializing - ProcPointer" );
503
504 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Procedure );
505 }
506
[184]507public:
[206]508 ProcPointer( Kind kind )
[208]509 : Procedure( NamespaceScopes(), std::string(), kind, false )
[184]510 {
511 }
[206]512 ProcPointer()
513 {
514 }
515 ~ProcPointer(){}
[184]516};
517
[523]518class ProcPointers : public std::vector<ProcPointer *>
[184]519{
[206]520 // XMLシリアライズ用
521private:
522 friend class boost::serialization::access;
523 template<class Archive> void serialize(Archive& ar, const unsigned int version)
524 {
525 trace_for_serialize( "serializing - ProcPointers" );
526
527 ar & boost::serialization::make_nvp("vector_ProcPointer",
528 boost::serialization::base_object<vector<ProcPointer *>>(*this));
529 }
530
[184]531public:
[206]532 ProcPointers()
[184]533 {
534 }
[206]535 ~ProcPointers()
[184]536 {
537 Clear();
538 }
539
[271]540 void Clear();
541 void PullOutAll()
542 {
543 clear();
544 }
[184]545};
Note: See TracBrowser for help on using the repository browser.