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

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

ジェネリッククラスの型パラメータに値型が指定されたときに限り、テンプレート展開を行うようにした。

TODO: libファイルを跨ってテンプレート展開ができていないため、ソースコード管理部分に手を加える必要あり。

File size: 11.2 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
[632]26private:
[206]27 // ソースコードの位置
[632]28 SourceCodePosition sourceCodePosition;
[206]29
30 // XMLシリアライズ用
31private:
32 friend class boost::serialization::access;
[208]33 template<class Archive> void serialize(Archive& ar, const unsigned int version)
[184]34 {
[206]35 trace_for_serialize( "serializing - Procedure" );
36
[208]37 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol );
[206]38 ar & BOOST_SERIALIZATION_NVP( kind );
39 ar & BOOST_SERIALIZATION_NVP( isCdecl );
40 ar & BOOST_SERIALIZATION_NVP( isUsing );
41 ar & BOOST_SERIALIZATION_NVP( params );
42 ar & BOOST_SERIALIZATION_NVP( returnType );
[632]43 ar & BOOST_SERIALIZATION_NVP( sourceCodePosition );
[184]44 }
[206]45
46public:
[523]47 Procedure( const NamespaceScopes &namespaceScopes, const std::string &name, Kind kind, bool isCdecl )
[208]48 : Symbol( namespaceScopes, name )
[206]49 , kind( kind )
50 , isCdecl( isCdecl )
51 , isUsing( false )
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
[632]85 const SourceCodePosition &GetSourceCodePosition() const
[206]86 {
[632]87 return sourceCodePosition;
[206]88 }
[632]89 void SetSourceCodePosition( const SourceCodePosition &sourceCodePosition )
[572]90 {
[632]91 this->sourceCodePosition = sourceCodePosition;
[572]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
[632]180 UserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const std::string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport );
181 UserProc( const UserProc &userProc, const CClass *pParentClass );
182 UserProc();
183 ~UserProc();
[206]184
[511]185 void SetReturnType( const Type &newReturnType )
186 {
187 returnType = newReturnType;
188 }
189
[206]190 virtual const std::string &GetKeyName() const
191 {
192 return GetName();
193 }
194
[209]195 virtual bool IsDuplication( const UserProc *pUserProc ) const
196 {
[326]197 if( this->GetParentClassPtr() == pUserProc->GetParentClassPtr() // 親クラスが等しい
[353]198 && this->pInterface == pUserProc->pInterface // インターフェイスが等しい
[326]199 && pUserProc->IsEqualSymbol( *this ) // 名前空間及び名前が等しい
200 && this->Params().Equals( pUserProc->Params() ) // パラメータが等しい
201 && this->returnType.Equals( pUserProc->returnType ) ) // 戻り値が等しい
[209]202 {
203 return true;
204 }
205 return false;
206 }
207
[382]208 /*!
209 @brief オーバーライド用に関数同士が等しいかどうかをチェックする
210 @param actualTypeParametersForThisProc thisオブジェクトで保有するメソッドを対象とした実型パラメータ
211 pUserProc 照らし合わせる関数
212 */
213 bool IsEqualForOverride( const Types &actualTypeParametersForThisProc, const UserProc *pUserProc ) const;
[351]214
[206]215 bool IsMacro() const
216 {
217 return isMacro;
218 }
219
220 int GetSecondParmNum() const
221 {
222 return secondParmNum;
223 }
[572]224 void SetSecondParmNum( int secondParmNum )
225 {
226 this->secondParmNum = secondParmNum;
227 }
[206]228 const Parameters &RealParams() const
229 {
230 return realParams;
231 }
[572]232 Parameters &RealParams()
233 {
234 return realParams;
235 }
[511]236 void SetRealParams( const Parameters &params )
237 {
238 realParams = params;
239 }
[206]240 int GetRealSecondParmNum() const
241 {
242 return realSecondParmNum;
243 }
244
245 void ExportOff(){
246 isExport = false;
247 }
248 bool IsExport() const
249 {
250 return isExport;
251 }
252 void ThisIsSystemProc() const
253 {
254 isSystem = true;
255 }
256 bool IsSystem() const
257 {
258 return isSystem;
259 }
260 void ThisIsAutoGenerationProc() const
261 {
262 isAutoGeneration = true;
263 }
264 bool IsAutoGeneration() const
265 {
266 return isAutoGeneration;
267 }
268 void CompleteCompile() const
269 {
270 isCompiled = true;
271 }
272 void KillCompileStatus() const
273 {
274 isCompiled = false;
275 }
276 bool IsCompiled() const
277 {
278 return isCompiled;
279 }
280 bool IsDestructor() const
281 {
282 return ( GetName()[0] == '~' );
283 }
284
285 // バイナリコード位置とサイズ
286 DWORD GetBeginOpAddress() const
287 {
288 return beginOpAddress;
289 }
290 void SetBeginOpAddress( DWORD beginOpAddress ) const
291 {
292 this->beginOpAddress = beginOpAddress;
293 }
294 DWORD GetEndOpAddress() const
295 {
296 return endOpAddress;
297 }
298 void SetEndOpAddress( DWORD endOpAddress ) const
299 {
300 this->endOpAddress = endOpAddress;
301 }
302 int GetCodeSize() const
303 {
304 return endOpAddress - beginOpAddress;
305 }
306
[208]307 virtual const NamespaceScopes &GetNamespaceScopes() const;
[206]308 const NamespaceScopesCollection &GetImportedNamespaces() const;
309
310 Variables &GetLocalVars() const
311 {
312 return localVars;
313 }
314
315 int GetId() const
316 {
317 return id;
318 }
319
[257]320 const NativeCode &GetNativeCode() const
321 {
322 return nativeCode;
323 }
[225]324 NativeCode &GetNativeCode()
325 {
326 return nativeCode;
327 }
328
[206]329 std::string GetFullName() const;
[350]330 bool IsCastOperator() const;
[206]331
332 bool IsVirtual() const;
333
334 void SetParentClass( const CClass *pParentClass ){
335 this->pParentClass = pParentClass;
336 }
337 const CClass *GetParentClassPtr() const
338 {
339 return pParentClass;
340 }
341 const CClass &GetParentClass() const
342 {
343 return *pParentClass;
344 }
345 bool HasParentClass() const
346 {
347 return ( pParentClass != NULL );
348 }
[208]349 bool IsGlobalProcedure() const
350 {
351 return ( pParentClass == NULL );
352 }
[353]353 void SetInterface( const Interface *pInterface )
354 {
355 this->pInterface = pInterface;
356 }
[206]357 void SetMethod( CMethod *pMethod ){
358 this->pMethod = pMethod;
359 }
[336]360 const CMethod &GetMethod() const;
[206]361
362
[364]363 static const UserProc *pGlobalProc;
[184]364};
365
[206]366class UserProcs : public Jenga::Common::Hashmap<UserProc>
[184]367{
[206]368 // XMLシリアライズ用
369private:
370 friend class boost::serialization::access;
371 template<class Archive> void serialize(Archive& ar, const unsigned int version)
372 {
373 trace_for_serialize( "serializing - UserProcs" );
374
375 ar & boost::serialization::make_nvp("Hashmap_UserProcImpl",
376 boost::serialization::base_object<Jenga::Common::Hashmap<UserProc>>(*this));
377 }
378
379
[184]380public:
[206]381 UserProcs()
[184]382 {
383 }
[206]384 ~UserProcs()
385 {
386 }
[184]387
[576]388 void EnumGlobalProcs( const char *simpleName, const Symbol &localSymbol, std::vector<const UserProc *> &subs );
[206]389};
390
[209]391class DllProc : public Procedure, public Jenga::Common::ObjectInHashmap<DllProc>
[206]392{
[523]393 std::string dllFileName;
394 std::string alias;
[206]395 int lookupAddress;
396
397 // XMLシリアライズ用
398private:
399 friend class boost::serialization::access;
400 template<class Archive> void serialize(Archive& ar, const unsigned int version)
401 {
402 trace_for_serialize( "serializing - DllProc" );
403
404 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Procedure );
405 ar & BOOST_SERIALIZATION_NVP( dllFileName );
406 ar & BOOST_SERIALIZATION_NVP( alias );
407 ar & BOOST_SERIALIZATION_NVP( lookupAddress );
408 }
409
410public:
[523]411 DllProc( const NamespaceScopes &namespaceScopes, const std::string &name, Kind kind, bool isCdecl, const std::string &dllFileName, const std::string &alias )
[210]412 : Procedure( namespaceScopes, name, kind, isCdecl )
413 , dllFileName( dllFileName )
414 , alias( alias )
415 , lookupAddress( 0 )
[206]416 {
417 }
[210]418 DllProc()
419 {
420 }
[209]421 ~DllProc()
422 {
423 }
[206]424
[209]425 virtual const std::string &GetKeyName() const
426 {
427 return GetName();
428 }
429
430 virtual bool IsDuplication( const DllProc *pDllProc ) const
431 {
432 if( pDllProc->IsEqualSymbol( *this )
433 && this->Params().Equals( pDllProc->Params() ) )
434 {
435 return true;
436 }
437 return false;
438 }
439
[523]440 const std::string &GetDllFileName() const
[206]441 {
442 return dllFileName;
443 }
[523]444 const std::string &GetAlias() const
[206]445 {
446 return alias;
447 }
448
449 void SetLookupAddress( int lookupAddress ){
450 this->lookupAddress = lookupAddress;
451 }
452 int GetLookupAddress() const
453 {
454 return lookupAddress;
455 }
[184]456};
[209]457class DllProcs : public Jenga::Common::Hashmap<DllProc>
458{
459 // XMLシリアライズ用
460private:
461 friend class boost::serialization::access;
462 template<class Archive> void serialize(Archive& ar, const unsigned int version)
463 {
464 trace_for_serialize( "serializing - DllProcs" );
[184]465
[209]466 ar & boost::serialization::make_nvp("Hashmap_DllProc",
467 boost::serialization::base_object<Jenga::Common::Hashmap<DllProc>>(*this));
468 }
469};
470
[206]471class ProcPointer : public Procedure
[184]472{
[206]473 // XMLシリアライズ用
474private:
475 friend class boost::serialization::access;
476 template<class Archive> void serialize(Archive& ar, const unsigned int version)
477 {
478 trace_for_serialize( "serializing - ProcPointer" );
479
480 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Procedure );
481 }
482
[184]483public:
[206]484 ProcPointer( Kind kind )
[208]485 : Procedure( NamespaceScopes(), std::string(), kind, false )
[184]486 {
487 }
[206]488 ProcPointer()
489 {
490 }
491 ~ProcPointer(){}
[184]492};
493
[523]494class ProcPointers : public std::vector<ProcPointer *>
[184]495{
[206]496 // XMLシリアライズ用
497private:
498 friend class boost::serialization::access;
499 template<class Archive> void serialize(Archive& ar, const unsigned int version)
500 {
501 trace_for_serialize( "serializing - ProcPointers" );
502
503 ar & boost::serialization::make_nvp("vector_ProcPointer",
504 boost::serialization::base_object<vector<ProcPointer *>>(*this));
505 }
506
[184]507public:
[206]508 ProcPointers()
[184]509 {
510 }
[206]511 ~ProcPointers()
[184]512 {
513 Clear();
514 }
515
[271]516 void Clear();
517 void PullOutAll()
518 {
519 clear();
520 }
[184]521};
Note: See TracBrowser for help on using the repository browser.