[206] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[639] | 3 | bool CMethod::Resolve( const ObjectModule &resolver )
|
---|
| 4 | {
|
---|
| 5 | if( pUserProc )
|
---|
| 6 | {
|
---|
| 7 | if( pUserProc->IsNeedResolve() )
|
---|
| 8 | {
|
---|
| 9 | pUserProc = resolver.meta.GetUserProcs().FindLike( pUserProc );
|
---|
| 10 | }
|
---|
| 11 | }
|
---|
| 12 | return true;
|
---|
| 13 | }
|
---|
| 14 |
|
---|
[558] | 15 | DynamicMethod::OverrideResult::EnumType DynamicMethod::Override( const UserProc *pUserProc, Prototype::Accessibility accessibility, bool isOverrideModifier )
|
---|
[351] | 16 | {
|
---|
[558] | 17 | bool isAbstractBefore = this->IsAbstract();
|
---|
[351] | 18 |
|
---|
| 19 | //メンバ関数を上書き
|
---|
| 20 | this->SetUserProcPtr( pUserProc );
|
---|
| 21 | this->SetAbstractMark( false );
|
---|
| 22 |
|
---|
[558] | 23 | if( this->IsVirtual() )
|
---|
[351] | 24 | {
|
---|
[558] | 25 | if( !isAbstractBefore && isOverrideModifier == false )
|
---|
| 26 | {
|
---|
| 27 | return OverrideResult::NotUseOverrideModifier;
|
---|
| 28 | }
|
---|
[351] | 29 | }
|
---|
[558] | 30 | else
|
---|
[351] | 31 | {
|
---|
[558] | 32 | return OverrideResult::NotVirtual;
|
---|
[351] | 33 | }
|
---|
| 34 |
|
---|
[558] | 35 | if( this->GetAccessibility() != accessibility )
|
---|
| 36 | {
|
---|
| 37 | return OverrideResult::DifferentAccesibility;
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | return OverrideResult::Successful;
|
---|
[351] | 41 | }
|
---|
| 42 |
|
---|
[639] | 43 | bool DynamicMethod::Resolve( const ObjectModule &resolver )
|
---|
| 44 | {
|
---|
| 45 | CMethod::Resolve( resolver );
|
---|
[351] | 46 |
|
---|
[639] | 47 | if( this->pInheritsClass )
|
---|
| 48 | {
|
---|
| 49 | if( this->pInheritsClass->IsNeedResolve() )
|
---|
| 50 | {
|
---|
| 51 | this->pInheritsClass = resolver.meta.GetClasses().FindLike( pInheritsClass );
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | return true;
|
---|
| 56 | }
|
---|
| 57 |
|
---|
[351] | 58 | StaticMethod::StaticMethod( const StaticMethod &staticMethod )
|
---|
| 59 | {
|
---|
| 60 | // 静的メソッドがコピーコンストラトされることは想定しない
|
---|
[559] | 61 | throw;
|
---|
[351] | 62 | }
|
---|
| 63 |
|
---|
[639] | 64 | bool StaticMethod::Resolve( const ObjectModule &resolver )
|
---|
| 65 | {
|
---|
| 66 | CMethod::Resolve( resolver );
|
---|
| 67 | return true;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 |
|
---|
[206] | 71 | Methods::Methods()
|
---|
| 72 | {
|
---|
| 73 | }
|
---|
[351] | 74 |
|
---|
| 75 | // コピーコンストラクタ
|
---|
| 76 | Methods::Methods( const Methods &methods )
|
---|
| 77 | {
|
---|
| 78 | BOOST_FOREACH( CMethod *pMethod, methods )
|
---|
| 79 | {
|
---|
| 80 | this->push_back( new DynamicMethod( dynamic_cast<DynamicMethod &>(*pMethod) ) );
|
---|
| 81 | }
|
---|
| 82 | }
|
---|
| 83 |
|
---|
[206] | 84 | Methods::~Methods()
|
---|
| 85 | {
|
---|
| 86 | Methods &methods = *this;
|
---|
[351] | 87 | BOOST_FOREACH( CMethod *pMethod, methods )
|
---|
| 88 | {
|
---|
[206] | 89 | delete pMethod;
|
---|
| 90 | }
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | void Methods::Add( UserProc *pUserProc,Prototype::Accessibility accessibility, bool isConst, bool isAbstract, bool isVirtual ){
|
---|
| 94 | CMethod *pMethod = new DynamicMethod( pUserProc, accessibility, isAbstract, isVirtual, isConst );
|
---|
| 95 | this->push_back( pMethod );
|
---|
| 96 | pUserProc->SetMethod( pMethod );
|
---|
| 97 | }
|
---|
| 98 | void Methods::AddStatic(UserProc *pUserProc, Prototype::Accessibility accessibility ){
|
---|
| 99 | CMethod *pMethod = new StaticMethod( pUserProc, accessibility );
|
---|
| 100 | this->push_back( pMethod );
|
---|
| 101 | pUserProc->SetMethod( pMethod );
|
---|
| 102 | }
|
---|
| 103 |
|
---|
[558] | 104 | DynamicMethod *Methods::FindForOverride( const Types &actualTypeParametersForThisMethods, const UserProc *pUserProc )
|
---|
[346] | 105 | {
|
---|
| 106 | //メソッドのオーバーライド
|
---|
| 107 | Methods &methods = *this;
|
---|
| 108 | BOOST_FOREACH( CMethod *pMethod, methods )
|
---|
| 109 | {
|
---|
[382] | 110 | if( !pMethod->IsNotUse() && pMethod->GetUserProc().IsEqualForOverride( actualTypeParametersForThisMethods, pUserProc ) )
|
---|
[346] | 111 | {
|
---|
[558] | 112 | return dynamic_cast<DynamicMethod *>(pMethod);
|
---|
[346] | 113 | }
|
---|
| 114 | }
|
---|
[351] | 115 | return NULL;
|
---|
[346] | 116 | }
|
---|
| 117 |
|
---|
[206] | 118 | const CMethod *Methods::GetMethodPtr( const UserProc *pUserProc ) const
|
---|
| 119 | {
|
---|
| 120 | const Methods &methods = *this;
|
---|
| 121 | for( int i=(int)methods.size()-1; i>=0; i-- ){
|
---|
| 122 | if( pUserProc == &methods[i]->GetUserProc() ){
|
---|
| 123 | return methods[i];
|
---|
| 124 | }
|
---|
| 125 | }
|
---|
| 126 | return NULL;
|
---|
| 127 | }
|
---|
| 128 | bool Methods::IsExist( const char *name ) const
|
---|
| 129 | {
|
---|
| 130 | const Methods &methods = *this;
|
---|
| 131 | BOOST_FOREACH( const CMethod *pMethod, methods ){
|
---|
| 132 | if( pMethod->GetUserProc().GetName() == name ) return true;
|
---|
| 133 | }
|
---|
| 134 | return false;
|
---|
| 135 | }
|
---|
[523] | 136 | void Methods::Enum( const char *methodName, std::vector<const UserProc *> &subs ) const
|
---|
[206] | 137 | {
|
---|
| 138 | //オブジェクトのメンバ関数の場合
|
---|
| 139 | //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う
|
---|
| 140 | const Methods &methods = *this;
|
---|
| 141 | for( int i=(int)methods.size()-1; i>=0; i-- ){
|
---|
[352] | 142 | if( methods[i]->GetUserProc().GetName() == methodName && methods[i]->IsNotUse() == false ){
|
---|
[206] | 143 | subs.push_back( &methods[i]->GetUserProc() );
|
---|
| 144 | }
|
---|
| 145 | }
|
---|
| 146 | }
|
---|
[523] | 147 | void Methods::Enum( BYTE idOperatorCalc, std::vector<const UserProc *> &subs ) const
|
---|
[206] | 148 | {
|
---|
| 149 | //オブジェクトのメンバ関数の場合
|
---|
| 150 | //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う
|
---|
| 151 | const Methods &methods = *this;
|
---|
| 152 | for( int i=(int)methods.size()-1; i>=0; i-- ){
|
---|
| 153 | const UserProc &userProc = methods[i]->GetUserProc();
|
---|
| 154 | const char *temp = userProc.GetName().c_str();
|
---|
| 155 | if(temp[0]==1&&temp[1]==ESC_OPERATOR){
|
---|
| 156 | if((BYTE)temp[2]==idOperatorCalc){
|
---|
| 157 | subs.push_back( &userProc );
|
---|
| 158 | }
|
---|
| 159 | }
|
---|
| 160 | }
|
---|
| 161 | }
|
---|
[347] | 162 |
|
---|
| 163 | int Methods::GetVtblNum() const
|
---|
| 164 | {
|
---|
| 165 | int count = 0;
|
---|
| 166 | const Methods &methods = *this;
|
---|
| 167 | BOOST_FOREACH( const CMethod *pMethod, methods )
|
---|
| 168 | {
|
---|
| 169 | if( pMethod->IsVirtual() )
|
---|
| 170 | {
|
---|
| 171 | count++;
|
---|
| 172 | }
|
---|
| 173 | }
|
---|
| 174 | return count;
|
---|
| 175 | }
|
---|