Changeset 560 in dev
- Timestamp:
- May 5, 2008, 12:49:01 PM (17 years ago)
- Location:
- trunk/ab5.0/abdev/BasicCompiler_Common
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/BasicCompiler_Common/include/Class.h
r559 r560 306 306 return ( interfaces.size() != 0 ); 307 307 } 308 void AddInterface( ::Interface *pInterface ) 309 { 310 interfaces.push_back( pInterface ); 311 } 308 312 const Interfaces &GetInterfaces() const 309 313 { … … 314 318 // クラス継承 315 319 bool InheritsClass( const CClass &inheritsClass, const Types &actualTypeParameters, int nowLine ); 316 317 // インターフェイス実装318 void Implements( const CClass &interfaceClass, const Types &actualTypeParameters, std::vector<DynamicMethod::OverrideResult> &overrideResults );319 320 320 321 //メンバ、メソッドの追加 -
trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h
r552 r560 46 46 static void AddMethod(CClass *pobj_c, UserProc *pUserProc, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract, 47 47 bool isVirtual, bool isOverride, const char *interfaceName, bool isAutoGeneration, int nowLine); 48 static bool Inherits( CClass ¤tClass, const char *inheritNames, int nowLine ); 49 static bool Implements( CClass ¤tClass, const char *interfaceNames, int nowLine ); 48 static bool Inherits( CClass &_class, const char *inheritNames, int nowLine ); 49 static void Implements( CClass &_class, Interface *pInterface, std::vector<DynamicMethod::OverrideResult> &overrideResults ); 50 static bool Implements( CClass &_class, const char *interfaceNames, int nowLine ); 50 51 static void LookaheadClass( const char *className, Classes &classes ); 51 52 static bool LoopRefCheck( const CClass &objClass ); -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Class.cpp
r559 r560 183 183 184 184 return true; 185 }186 187 void CClass::Implements( const CClass &interfaceClass, const Types &actualTypeParameters, std::vector<DynamicMethod::OverrideResult> &overrideResults )188 {189 ::Interface *pDestInterface = new ::Interface( &interfaceClass, actualTypeParameters );190 191 interfaces.push_back( pDestInterface );192 193 194 /////////////////////////////////////////////////////////////////195 // 基底クラスのメソッドからインターフェイスメソッドを再実装する196 /////////////////////////////////////////////////////////////////197 BOOST_FOREACH( CMethod *pMethod, GetDynamicMethods() )198 {199 DynamicMethod *pMethodForOverride = pDestInterface->GetDynamicMethods().FindForOverride( pDestInterface->GetActualTypeParameters(), &pMethod->GetUserProc() );200 if( pMethodForOverride )201 {202 DynamicMethod::OverrideResult result;203 result.enumType = pMethodForOverride->Override( &pMethod->GetUserProc(), pMethod->GetAccessibility(), false );204 result.pMethod = pMethod;205 overrideResults.push_back( result );206 207 // 実装元になるメソッドは呼び出し不可にしておく(オーバーロードの解決から除外する)208 pMethod->SetNotUseMark( true );209 }210 }211 212 213 /////////////////////////////////////////////////////////////////214 // キャストメソッドを追加(内部コードは自動生成すること)215 /////////////////////////////////////////////////////////////////216 if( interfaceClass.IsInterface() )217 {218 // Function Operator() As ITest219 220 char methodName[255] = { 1, ESC_OPERATOR, CALC_AS, '\0' };221 222 //関数ハッシュへ登録223 UserProc *pUserProc = new UserProc(224 NamespaceScopes(),225 NamespaceScopesCollection(),226 methodName,227 Procedure::Function,228 false,229 false,230 false );231 pUserProc->SetParentClass( this );232 233 Parameters params;234 params.push_back( new Parameter( "_System_LocalThis", Type( DEF_PTR_VOID ) ) );235 pUserProc->SetRealParams( params );236 237 pUserProc->SetReturnType( Type( DEF_OBJECT, interfaceClass ) );238 pUserProc->_paramStr = "";239 pUserProc->Using();240 compiler.GetObjectModule().meta.GetUserProcs().Insert( pUserProc, -1 );241 242 LexicalAnalyzer::AddMethod(this,243 pUserProc,244 Prototype::Public,245 0,246 false, // isConst247 false, // isAbstract248 false, // isVirtual249 false, // isOverride250 "",251 true, // isAutoGeneration252 -1253 );254 }255 185 } 256 186 -
trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Class.cpp
r558 r560 408 408 } 409 409 410 bool LexicalAnalyzer::Inherits( CClass & currentClass, const char *inheritNames, int nowLine ){410 bool LexicalAnalyzer::Inherits( CClass &_class, const char *inheritNames, int nowLine ){ 411 411 int i = 0; 412 412 bool isInheritsClass = false; … … 462 462 } 463 463 464 if( ! currentClass.InheritsClass( *pInheritsClass, actualTypeParameters, nowLine ) ){464 if( !_class.InheritsClass( *pInheritsClass, actualTypeParameters, nowLine ) ){ 465 465 return false; 466 466 } … … 495 495 496 496 // クラスを一つも継承していないとき 497 if( ! currentClass.InheritsClass( *pObjectClass, Types(), nowLine ) ){497 if( !_class.InheritsClass( *pObjectClass, Types(), nowLine ) ){ 498 498 return false; 499 499 } … … 503 503 } 504 504 505 bool LexicalAnalyzer::Implements( CClass ¤tClass, const char *interfaceNames, int nowLine ) 505 void LexicalAnalyzer::Implements( CClass &_class, Interface *pInterface, std::vector<DynamicMethod::OverrideResult> &overrideResults ) 506 { 507 _class.AddInterface( pInterface ); 508 509 510 ///////////////////////////////////////////////////////////////// 511 // 基底クラスのメソッドからインターフェイスメソッドを再実装する 512 ///////////////////////////////////////////////////////////////// 513 BOOST_FOREACH( CMethod *pMethod, _class.GetDynamicMethods() ) 514 { 515 DynamicMethod *pMethodForOverride = pInterface->GetDynamicMethods().FindForOverride( pInterface->GetActualTypeParameters(), &pMethod->GetUserProc() ); 516 if( pMethodForOverride ) 517 { 518 DynamicMethod::OverrideResult result; 519 result.enumType = pMethodForOverride->Override( &pMethod->GetUserProc(), pMethod->GetAccessibility(), false ); 520 result.pMethod = pMethod; 521 overrideResults.push_back( result ); 522 523 // 実装元になるメソッドは呼び出し不可にしておく(オーバーロードの解決から除外する) 524 pMethod->SetNotUseMark( true ); 525 } 526 } 527 528 529 ///////////////////////////////////////////////////////////////// 530 // キャストメソッドを追加(内部コードは自動生成すること) 531 // ※COMインターフェイスは除外すること 532 ///////////////////////////////////////////////////////////////// 533 if( pInterface->GetClass().IsInterface() ) 534 { 535 // Function Operator() As ITest 536 537 char methodName[255] = { 1, ESC_OPERATOR, CALC_AS, '\0' }; 538 539 //関数ハッシュへ登録 540 UserProc *pUserProc = new UserProc( 541 NamespaceScopes(), 542 NamespaceScopesCollection(), 543 methodName, 544 Procedure::Function, 545 false, 546 false, 547 false ); 548 pUserProc->SetParentClass( &_class ); 549 550 Parameters params; 551 params.push_back( new Parameter( "_System_LocalThis", Type( DEF_PTR_VOID ) ) ); 552 pUserProc->SetRealParams( params ); 553 554 pUserProc->SetReturnType( Type( DEF_OBJECT, pInterface->GetClass() ) ); 555 pUserProc->_paramStr = ""; 556 pUserProc->Using(); 557 compiler.GetObjectModule().meta.GetUserProcs().Insert( pUserProc, -1 ); 558 559 LexicalAnalyzer::AddMethod( 560 &_class, 561 pUserProc, 562 Prototype::Public, 563 0, 564 false, // isConst 565 false, // isAbstract 566 false, // isVirtual 567 false, // isOverride 568 "", 569 true, // isAutoGeneration 570 -1 571 ); 572 } 573 } 574 575 bool LexicalAnalyzer::Implements( CClass &_class, const char *interfaceNames, int nowLine ) 506 576 { 507 577 Jenga::Common::Strings paramStrs; … … 541 611 // インターフェイスを継承する 542 612 std::vector<DynamicMethod::OverrideResult> overrideResults; 543 currentClass.Implements( *pInterfaceClass, actualTypeParameters, overrideResults ); 613 Implements( 614 _class, 615 new ::Interface( pInterfaceClass, actualTypeParameters ), 616 overrideResults 617 ); 544 618 545 619 // エラーチェック
Note:
See TracChangeset
for help on using the changeset viewer.