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

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

・デバッグトレース時、グローバル領域の終端行でステップインまたはステップアウトしたときにデバッグ情報の取得に失敗して強制終了してしまう不具合を修正。
・グローバル領域のデバッグ実行ができなくなっている不具合を修正。

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