Changeset 558 in dev for trunk/ab5.0/abdev/BasicCompiler_Common/src
- Timestamp:
- May 5, 2008, 10:41:25 AM (17 years ago)
- Location:
- trunk/ab5.0/abdev/BasicCompiler_Common/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/BasicCompiler_Common/src/Class.cpp
r557 r558 185 185 } 186 186 187 void CClass::Implements( const CClass &interfaceClass, const Types &actualTypeParameters, int nowLine)187 void CClass::Implements( const CClass &interfaceClass, const Types &actualTypeParameters, std::vector<DynamicMethod::OverrideResult> &overrideResults ) 188 188 { 189 189 ::Interface *pDestInterface = new ::Interface( &interfaceClass, actualTypeParameters ); … … 197 197 BOOST_FOREACH( CMethod *pMethod, GetDynamicMethods() ) 198 198 { 199 CMethod *pMethodForOverride = pDestInterface->GetDynamicMethods().FindForOverride( pDestInterface->GetActualTypeParameters(), &pMethod->GetUserProc() );199 DynamicMethod *pMethodForOverride = pDestInterface->GetDynamicMethods().FindForOverride( pDestInterface->GetActualTypeParameters(), &pMethod->GetUserProc() ); 200 200 if( pMethodForOverride ) 201 201 { 202 pMethodForOverride->Override( &pMethod->GetUserProc(), pMethod->GetAccessibility(), false ); 202 DynamicMethod::OverrideResult result; 203 result.enumType = pMethodForOverride->Override( &pMethod->GetUserProc(), pMethod->GetAccessibility(), false ); 204 result.pMethod = pMethod; 205 overrideResults.push_back( result ); 203 206 204 207 // 実装元になるメソッドは呼び出し不可にしておく(オーバーロードの解決から除外する) -
trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Class.cpp
r557 r558 248 248 } 249 249 250 void OverrideErrorCheck( const DynamicMethod::OverrideResult &result ) 251 { 252 switch( result.enumType ) 253 { 254 case DynamicMethod::OverrideResult::Successful: 255 break; 256 case DynamicMethod::OverrideResult::NotVirtual: 257 compiler.errorMessenger.Output(136, result.pMethod->GetUserProc().GetName(), cp); 258 break; 259 case DynamicMethod::OverrideResult::NotUseOverrideModifier: 260 compiler.errorMessenger.Output(127, result.pMethod->GetUserProc().GetName(), cp); 261 break; 262 case DynamicMethod::OverrideResult::DifferentAccesibility: 263 compiler.errorMessenger.Output(128, result.pMethod->GetUserProc().GetName(), cp); 264 break; 265 default: 266 throw; 267 } 268 } 269 250 270 void LexicalAnalyzer::AddMethod(CClass *pobj_c, UserProc *pUserProc, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract, 251 271 bool isVirtual, bool isOverride, const char *interfaceName, bool isAutoGeneration, int nowLine) … … 320 340 321 341 // メソッドのオーバーライド 322 CMethod *pMethodForOverride = pobj_c->GetDynamicMethods().FindForOverride( pobj_c->GetSuperClassActualTypeParameters(), pUserProc );342 DynamicMethod *pMethodForOverride = pobj_c->GetDynamicMethods().FindForOverride( pobj_c->GetSuperClassActualTypeParameters(), pUserProc ); 323 343 if( pMethodForOverride ) 324 344 { 325 pMethodForOverride->Override( pUserProc, accessibility, isOverride ); 345 DynamicMethod::OverrideResult result; 346 result.enumType = pMethodForOverride->Override( pUserProc, accessibility, isOverride ); 347 result.pMethod = pMethodForOverride; 348 OverrideErrorCheck( result ); 349 326 350 pUserProc->SetMethod( pMethodForOverride ); 327 351 return; … … 349 373 } 350 374 351 CMethod *pMethodForOverride = pInterface->GetDynamicMethods().FindForOverride( pInterface->GetActualTypeParameters(), pUserProc );375 DynamicMethod *pMethodForOverride = pInterface->GetDynamicMethods().FindForOverride( pInterface->GetActualTypeParameters(), pUserProc ); 352 376 if( pMethodForOverride ) 353 377 { 354 pMethodForOverride->Override( pUserProc, accessibility, isOverride ); 378 DynamicMethod::OverrideResult result; 379 result.enumType = pMethodForOverride->Override( pUserProc, accessibility, isOverride ); 380 result.pMethod = pMethodForOverride; 381 OverrideErrorCheck( result ); 382 355 383 pUserProc->SetMethod( pMethodForOverride ); 356 384 return; … … 512 540 { 513 541 // インターフェイスを継承する 514 currentClass.Implements( *pInterfaceClass, actualTypeParameters, nowLine ); 542 std::vector<DynamicMethod::OverrideResult> overrideResults; 543 currentClass.Implements( *pInterfaceClass, actualTypeParameters, overrideResults ); 544 545 // エラーチェック 546 BOOST_FOREACH( const DynamicMethod::OverrideResult result, overrideResults ) 547 { 548 OverrideErrorCheck( result ); 549 } 515 550 } 516 551 else -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Method.cpp
r523 r558 4 4 5 5 6 boolDynamicMethod::Override( const UserProc *pUserProc, Prototype::Accessibility accessibility, bool isOverrideModifier )6 DynamicMethod::OverrideResult::EnumType DynamicMethod::Override( const UserProc *pUserProc, Prototype::Accessibility accessibility, bool isOverrideModifier ) 7 7 { 8 if( this->IsVirtual() 9 && !this->IsAbstract() 10 && isOverrideModifier == false ) 11 { 12 // Override修飾子が無い状況で基底クラスの実体メソッドをオーバーライドしようとした 13 compiler.errorMessenger.Output(127,NULL,cp); 14 } 8 bool isAbstractBefore = this->IsAbstract(); 15 9 16 10 //メンバ関数を上書き … … 18 12 this->SetAbstractMark( false ); 19 13 20 if( !this->IsVirtual() )14 if( this->IsVirtual() ) 21 15 { 22 // オーバーライドミス 23 compiler.errorMessenger.Output(136, pUserProc->GetName(), cp); 16 if( !isAbstractBefore && isOverrideModifier == false ) 17 { 18 return OverrideResult::NotUseOverrideModifier; 19 } 24 20 } 25 if(this->GetAccessibility() != accessibility )21 else 26 22 { 27 compiler.errorMessenger.Output(128,NULL,cp);23 return OverrideResult::NotVirtual; 28 24 } 29 25 30 return true; 26 if( this->GetAccessibility() != accessibility ) 27 { 28 return OverrideResult::DifferentAccesibility; 29 } 30 31 return OverrideResult::Successful; 31 32 } 32 33 … … 71 72 } 72 73 73 CMethod *Methods::FindForOverride( const Types &actualTypeParametersForThisMethods, const UserProc *pUserProc )74 DynamicMethod *Methods::FindForOverride( const Types &actualTypeParametersForThisMethods, const UserProc *pUserProc ) 74 75 { 75 76 //メソッドのオーバーライド … … 79 80 if( !pMethod->IsNotUse() && pMethod->GetUserProc().IsEqualForOverride( actualTypeParametersForThisMethods, pUserProc ) ) 80 81 { 81 return pMethod;82 return dynamic_cast<DynamicMethod *>(pMethod); 82 83 } 83 84 }
Note:
See TracChangeset
for help on using the changeset viewer.