Changeset 50 in dev for BasicCompiler_Common/Class.cpp
- Timestamp:
- Feb 10, 2007, 5:44:58 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/Class.cpp
r46 r50 142 142 cp=pobj_c->ppobj_StaticMember[i]->source_code_address; 143 143 144 CallConstr actor(temporary,144 CallConstructor(temporary, 145 145 pobj_c->ppobj_StaticMember[i]->SubScripts, 146 146 pobj_c->ppobj_StaticMember[i]->TypeInfo, … … 225 225 } 226 226 227 if(ppobj_StaticMethod){ 228 //静的メソッド 229 for(i=0;i<iStaticMethodNum;i++){ 230 delete ppobj_StaticMethod[i]; 231 } 232 HeapDefaultFree(ppobj_StaticMethod); 233 ppobj_StaticMethod=0; 227 foreach( CMethod *method, StaticMethods ){ 228 delete method; 234 229 } 235 230 } … … 306 301 } 307 302 void CClass::AddStaticMethod(SUBINFO *psi,DWORD dwAccess){ 308 ppobj_StaticMethod=(CMethod **)HeapReAlloc(hHeap,0,ppobj_StaticMethod,(iStaticMethodNum+1)*sizeof(CMethod *)); 309 ppobj_StaticMethod[iStaticMethodNum]=new CMethod(); 310 ppobj_StaticMethod[iStaticMethodNum]->psi=psi; 311 ppobj_StaticMethod[iStaticMethodNum]->dwAccess=dwAccess; 312 ppobj_StaticMethod[iStaticMethodNum]->bAbstract=0; 313 ppobj_StaticMethod[iStaticMethodNum]->bVirtual=0; 314 ppobj_StaticMethod[iStaticMethodNum]->pobj_InheritsClass=0; 315 316 iStaticMethodNum++; 303 CMethod *method = new CMethod(); 304 method->psi=psi; 305 method->dwAccess=dwAccess; 306 method->bAbstract=0; 307 method->bVirtual=0; 308 method->pobj_InheritsClass=0; 309 310 StaticMethods.push_back( method ); 317 311 } 318 312 BOOL CClass::DupliCheckAll(const char *name){ … … 355 349 } 356 350 CMethod *CClass::GetMethodInfo( SUBINFO *psi ){ 357 int i; 358 for( i=0; i<iMethodNum; i++ ){ 359 if( psi == ppobj_Method[i]->psi ) break; 360 } 361 if( i == iMethodNum ){ 362 return NULL; 363 } 364 return ppobj_Method[i]; 351 for( int i=iMethodNum-1; i>=0; i-- ){ 352 if( psi == ppobj_Method[i]->psi ) return ppobj_Method[i]; 353 } 354 return NULL; 365 355 } 366 356 CMethod *CClass::GetStaticMethodInfo( SUBINFO *psi ){ 367 int i; 368 for( i=0; i<iStaticMethodNum; i++ ){ 369 if( psi == ppobj_StaticMethod[i]->psi ) break; 370 } 371 if( i == iStaticMethodNum ){ 372 return NULL; 373 } 374 return ppobj_StaticMethod[i]; 357 for( int i=(int)StaticMethods.size()-1; i>=0; i-- ){ 358 if( psi == StaticMethods[i]->psi ) return StaticMethods[i]; 359 } 360 return NULL; 375 361 } 376 362 bool CClass::IsExistMethod( const char *name ){ … … 381 367 } 382 368 bool CClass::IsExistStaticMethod( const char *name ){ 383 for ( int i=0; i<iStaticMethodNum; i++){384 if( lstrcmp( ppobj_StaticMethod[i]->psi->name, name ) == 0 ) return true;369 foreach( CMethod *method, StaticMethods ){ 370 if( lstrcmp( method->psi->name, name ) == 0 ) return true; 385 371 } 386 372 return false; 373 } 374 375 void CClass::EnumStaticMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const 376 { 377 foreach( CMethod *method, StaticMethods ){ 378 if(lstrcmp(methodName,method->psi->name)==0){ 379 subs.push_back( method->psi ); 380 } 381 } 382 } 383 384 void CClass::EnumMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const 385 { 386 //オブジェクトのメンバ関数の場合 387 //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う 388 for(int i=iMethodNum-1;i>=0;i--){ 389 if(lstrcmp(name,ppobj_Method[i]->psi->name)==0){ 390 subs.push_back( ppobj_Method[i]->psi ); 391 } 392 } 393 } 394 395 void CClass::EnumMethod( const BYTE idOperatorCalc, std::vector<SUBINFO *> &subs ) const 396 { 397 for(int i=0;i<iMethodNum;i++){ 398 char *temp; 399 temp=ppobj_Method[i]->psi->name; 400 if(temp[0]==1&&temp[1]==ESC_OPERATOR){ 401 if((BYTE)temp[2]==idOperatorCalc){ 402 subs.push_back( ppobj_Method[i]->psi ); 403 } 404 } 405 } 387 406 } 388 407 … … 465 484 466 485 return false; 467 }468 469 470 SUBINFO **CClass::GetOperatorSubInfo(BYTE idCalc,int &num){471 //格納のための構造体配列を用意472 SUBINFO **ppArray_si;473 ppArray_si=(SUBINFO **)HeapAlloc(hHeap,0,sizeof(SUBINFO *)*1024);474 num=0;475 476 int i;477 for(i=0;i<iMethodNum;i++){478 char *temp;479 temp=ppobj_Method[i]->psi->name;480 if(temp[0]==1&&temp[1]==ESC_OPERATOR){481 if((BYTE)temp[2]==idCalc){482 ppArray_si[num]=ppobj_Method[i]->psi;483 num++;484 }485 }486 }487 488 return ppArray_si;489 486 } 490 487 … … 895 892 pobj_c->ppobj_Method=(CMethod **)HeapAlloc(hHeap,0,1); 896 893 pobj_c->iMethodNum=0; 897 pobj_c->ppobj_StaticMethod=(CMethod **)HeapAlloc(hHeap,0,1);898 pobj_c->iStaticMethodNum=0;899 894 900 895 pobj_c->ConstructorMemberSubIndex=-1; … … 1057 1052 pobj_c->ppobj_Method=(CMethod **)HeapAlloc(hHeap,0,1); 1058 1053 pobj_c->iMethodNum=0; 1059 pobj_c->ppobj_StaticMethod=(CMethod **)HeapAlloc(hHeap,0,1);1060 pobj_c->iStaticMethodNum=0;1061 1054 1062 1055 pobj_c->ConstructorMemberSubIndex=-1;
Note:
See TracChangeset
for help on using the changeset viewer.