Changeset 18 in dev for BasicCompiler_Common/Class.cpp
- Timestamp:
- Dec 24, 2006, 4:46:12 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/Class.cpp
r17 r18 11 11 CClass *pobj_CompilingClass; 12 12 CClass *pobj_StringClass; 13 14 CMember *pCompilingMethod; 13 15 14 16 int AddDataTable(char *buffer,int length); … … 170 172 lstrcpy(this->name,name); 171 173 172 isCompilingConstructor = 0; 174 isCompilingConstructor = false; 175 isCompilingDestructor = false; 173 176 } 174 177 CClass::~CClass(){ … … 224 227 iStaticMemberNum++; 225 228 } 226 void CClass::AddMethod(SUBINFO *psi,DWORD dwAccess,BOOL bAbstract,BOOL bVirtual){ 227 ppobj_Method=(CMethod **)HeapReAlloc(hHeap,0,ppobj_Method,(iMethodNum+1)*sizeof(CMethod *)); 228 ppobj_Method[iMethodNum]=new CMethod(); 229 ppobj_Method[iMethodNum]->psi=psi; 230 ppobj_Method[iMethodNum]->dwAccess=dwAccess; 231 ppobj_Method[iMethodNum]->bAbstract=bAbstract; 232 ppobj_Method[iMethodNum]->bVirtual=bVirtual; 233 ppobj_Method[iMethodNum]->pobj_InheritsClass=0; 229 void CClass::AddMethod( SUBINFO *psi,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual ){ 230 ppobj_Method = (CMethod **)HeapReAlloc( hHeap, 0, ppobj_Method, (iMethodNum + 1) * sizeof(CMethod *) ); 231 ppobj_Method[iMethodNum] = new CMethod(); 232 ppobj_Method[iMethodNum]->psi = psi; 233 ppobj_Method[iMethodNum]->dwAccess = dwAccess; 234 ppobj_Method[iMethodNum]->isConst = isConst; 235 ppobj_Method[iMethodNum]->bAbstract = bAbstract; 236 ppobj_Method[iMethodNum]->bVirtual = bVirtual; 237 ppobj_Method[iMethodNum]->pobj_InheritsClass = 0; 234 238 235 239 iMethodNum++; … … 284 288 return 0; 285 289 } 290 CMethod *CClass::GetMethodInfo( SUBINFO *psi ){ 291 int i; 292 for( i=0; i<iMethodNum; i++ ){ 293 if( psi == ppobj_Method[i]->psi ) break; 294 } 295 if( i == iMethodNum ){ 296 return NULL; 297 } 298 return ppobj_Method[i]; 299 } 300 CMethod *CClass::GetStaticMethodInfo( SUBINFO *psi ){ 301 int i; 302 for( i=0; i<iStaticMethodNum; i++ ){ 303 if( psi == ppobj_StaticMethod[i]->psi ) break; 304 } 305 if( i == iMethodNum ){ 306 return NULL; 307 } 308 return ppobj_StaticMethod[i]; 309 } 286 310 287 311 LONG_PTR CClass::AddVtblDataTable(SUBINFO **ppsi,int length){ … … 409 433 } 410 434 435 //デストラクタのコンパイルを開始 436 void CClass::NotifyStartDestructorCompile(){ 437 isCompilingDestructor = true; 438 } 439 440 //デストラクタのコンパイルを終了 441 void CClass::NotifyFinishDestructorCompile(){ 442 isCompilingDestructor = false; 443 } 444 445 //デストラクタをコンパイル中かどうかを判別 446 bool CClass::IsCompilingDestructor(){ 447 return isCompilingDestructor; 448 } 449 411 450 412 451 int CDBClass::hash(char *name){ … … 559 598 560 599 561 void CDBClass::AddMemberSub(CClass *pobj_c,DWORD dwAccess,BOOL bStatic,BOOL bAbstract,BOOL bVirtual,BOOL bOverride,char *buffer,int NowLine){ 600 void CDBClass::AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, BOOL bAbstract, 601 BOOL bVirtual, BOOL bOverride, char *buffer, int NowLine){ 562 602 int i,i2; 563 603 char temporary[VN_SIZE]; … … 580 620 581 621 //////////////////////////////////////////////////////////// 582 // コンストラクタ、デストラクタの アクセシビリティをチェック622 // コンストラクタ、デストラクタの場合の処理 583 623 //////////////////////////////////////////////////////////// 584 624 BOOL fConstructor=0,bDestructor=0; 585 625 586 626 if(lstrcmp(temporary,pobj_c->name)==0){ 627 //コンストラクタの場合 628 629 //標準コンストラクタ(引数なし) 587 630 if(psi->ParmNum==1) fConstructor=1; 631 632 //コピーコンストラクタ 588 633 if(psi->ParmNum==2){ 589 634 if(psi->pParmInfo[1].type==DEF_OBJECT&& 590 635 psi->pParmInfo[1].u.pobj_c==pobj_c) fConstructor=2; 591 636 } 637 638 //強制的にConst修飾子をつける 639 isConst = true; 592 640 } 593 641 else if(temporary[0]=='~'){ … … 599 647 } 600 648 if(fConstructor||bDestructor){ 649 // コンストラクタ、デストラクタのアクセシビリティをチェック 601 650 if(dwAccess!=ACCESS_PUBLIC){ 602 651 SetError(116,NULL,NowLine); 603 652 dwAccess=ACCESS_PUBLIC; 604 653 } 605 } 606 607 608 if(fConstructor==1) pobj_c->ConstructorMemberSubIndex=pobj_c->iMethodNum; 609 else if(fConstructor==2) pobj_c->CopyConstructorMemberSubIndex=pobj_c->iMethodNum; 610 else if(bDestructor) pobj_c->DestructorMemberSubIndex=pobj_c->iMethodNum; 654 655 //強制的にConst修飾子をつける 656 isConst = true; 657 } 658 659 if( fConstructor == 1 ) 660 pobj_c->ConstructorMemberSubIndex = pobj_c->iMethodNum; 661 else if( fConstructor == 2 ) 662 pobj_c->CopyConstructorMemberSubIndex = pobj_c->iMethodNum; 663 else if( bDestructor ) 664 pobj_c->DestructorMemberSubIndex = pobj_c->iMethodNum; 611 665 612 666 … … 678 732 } 679 733 else{ 680 pobj_c->AddMethod(psi, dwAccess,bAbstract,bVirtual);734 pobj_c->AddMethod(psi, dwAccess, isConst, bAbstract, bVirtual); 681 735 } 682 736 } … … 890 944 891 945 //メンバ関数を追加 892 AddMemberSub(pobj_c,ACCESS_PUBLIC,0,1,1,0,temporary,sub_address); 946 AddMethod(pobj_c, 947 ACCESS_PUBLIC, //Publicアクセス権 948 0, //Static指定なし 949 false, //Constではない 950 1, //Abstract 951 1, //Virtual 952 0, 953 temporary, 954 sub_address 955 ); 893 956 } 894 957 } … … 990 1053 } 991 1054 992 //メンバ 変数をコピー1055 //メンバをコピー 993 1056 pobj_c->ppobj_Member=(CMember **)HeapReAlloc( 994 1057 hHeap, … … 1006 1069 } 1007 1070 1008 //メ ンバ関数をコピー1071 //メソッドをコピー 1009 1072 pobj_c->ppobj_Method=(CMethod **)HeapReAlloc( 1010 1073 hHeap, … … 1042 1105 InheritsError: 1043 1106 1044 //メンバ 変数、関数を取得1107 //メンバとメソッドを取得 1045 1108 while(1){ 1046 1109 i++; … … 1180 1243 //メソッドを追加 1181 1244 cp=i; //エラー用 1182 AddMemberSub(pobj_c,dwAccess,bStatic,bAbstract,bVirtual,bOverride,temporary,sub_address); 1245 AddMethod(pobj_c, 1246 dwAccess, 1247 bStatic, 1248 isConst, 1249 bAbstract, 1250 bVirtual, 1251 bOverride, 1252 temporary, 1253 sub_address); 1183 1254 1184 1255 if(bAbstract) continue; … … 1223 1294 } 1224 1295 1296 void CDBClass::StartCompile( SUBINFO *psi ){ 1297 pCompilingClass = psi->pobj_ParentClass; 1298 if( pCompilingClass ){ 1299 pCompilingMethod = pCompilingClass->GetMethodInfo( psi ); 1300 if( !pCompilingMethod ){ 1301 pCompilingMethod = pCompilingClass->GetStaticMethodInfo( psi ); 1302 if( !pCompilingMethod ){ 1303 SetError(300,NULL,cp); 1304 } 1305 } 1306 } 1307 else{ 1308 pCompilingMethod = NULL; 1309 } 1310 } 1311 CClass *CDBClass::GetNowCompilingClass(){ 1312 return pCompilingClass; 1313 } 1314 CMethod *CDBClass::GetNowCompilingMethodInfo(){ 1315 return pCompilingMethod; 1316 } 1317 1225 1318 1226 1319
Note:
See TracChangeset
for help on using the changeset viewer.