source: dev/trunk/abdev/BasicCompiler_Common/src/Method.cpp@ 244

Last change on this file since 244 was 206, checked in by dai_9181, 17 years ago

コード全体のリファクタリングを実施

File size: 2.1 KB
Line 
1#include "stdafx.h"
2
3#include <Class.h>
4
5
6Methods::Methods()
7{
8}
9Methods::~Methods()
10{
11 Methods &methods = *this;
12 BOOST_FOREACH( CMethod *pMethod, methods ){
13 delete pMethod;
14 }
15}
16
17void Methods::Add( UserProc *pUserProc,Prototype::Accessibility accessibility, bool isConst, bool isAbstract, bool isVirtual ){
18 CMethod *pMethod = new DynamicMethod( pUserProc, accessibility, isAbstract, isVirtual, isConst );
19 this->push_back( pMethod );
20 pUserProc->SetMethod( pMethod );
21}
22void Methods::AddStatic(UserProc *pUserProc, Prototype::Accessibility accessibility ){
23 CMethod *pMethod = new StaticMethod( pUserProc, accessibility );
24 this->push_back( pMethod );
25 pUserProc->SetMethod( pMethod );
26}
27
28const CMethod *Methods::GetMethodPtr( const UserProc *pUserProc ) const
29{
30 const Methods &methods = *this;
31 for( int i=(int)methods.size()-1; i>=0; i-- ){
32 if( pUserProc == &methods[i]->GetUserProc() ){
33 return methods[i];
34 }
35 }
36 return NULL;
37}
38bool Methods::IsExist( const char *name ) const
39{
40 const Methods &methods = *this;
41 BOOST_FOREACH( const CMethod *pMethod, methods ){
42 if( pMethod->GetUserProc().GetName() == name ) return true;
43 }
44 return false;
45}
46void Methods::Enum( const char *methodName, vector<const UserProc *> &subs ) const
47{
48 //オブジェクトのメンバ関数の場合
49 //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う
50 const Methods &methods = *this;
51 for( int i=(int)methods.size()-1; i>=0; i-- ){
52 if( methods[i]->GetUserProc().GetName() == methodName ){
53 subs.push_back( &methods[i]->GetUserProc() );
54 }
55 }
56}
57void Methods::Enum( BYTE idOperatorCalc, vector<const UserProc *> &subs ) const
58{
59 //オブジェクトのメンバ関数の場合
60 //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う
61 const Methods &methods = *this;
62 for( int i=(int)methods.size()-1; i>=0; i-- ){
63 const UserProc &userProc = methods[i]->GetUserProc();
64 const char *temp = userProc.GetName().c_str();
65 if(temp[0]==1&&temp[1]==ESC_OPERATOR){
66 if((BYTE)temp[2]==idOperatorCalc){
67 subs.push_back( &userProc );
68 }
69 }
70 }
71}
Note: See TracBrowser for help on using the repository browser.