Changeset 51 in dev for BasicCompiler64
- Timestamp:
- Feb 10, 2007, 8:30:19 PM (18 years ago)
- Location:
- BasicCompiler64
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler64/CParameter.cpp
r50 r51 96 96 97 97 //call destructor 98 int i5 = types[i2].u.pobj_Class->DestructorMemberSubIndex;99 if( i5 != -1){100 op_call( types[i2].u.pobj_Class->ppobj_Method[i5]->psi );98 CMethod *method = types[i2].u.pobj_Class->GetDestructorMethod(); 99 if( method ){ 100 op_call( method->psi ); 101 101 } 102 102 … … 138 138 CalcType.type=NumOpe_GetType(Parameter,&BaseType,&CalcType.u.lpIndex); 139 139 140 if( pobj_Class->CopyConstructorMemberSubIndex!=-1&&141 CalcType.type==DEF_OBJECT&&CalcType.u.pobj_Class==pobj_Class){140 if( pobj_Class->GetCopyConstructorMethod() 141 && CalcType.type==DEF_OBJECT&&CalcType.u.pobj_Class==pobj_Class){ 142 142 //////////////////////////////////// 143 143 // コピーコンストラクタを呼び出す … … 160 160 161 161 //call constructor 162 op_call(pobj_Class-> ppobj_Method[pobj_Class->CopyConstructorMemberSubIndex]->psi);162 op_call(pobj_Class->GetCopyConstructorMethod()->psi); 163 163 164 164 … … 168 168 } 169 169 else{ 170 if( pobj_Class->ConstructorMemberSubIndex!=-1){170 if( pobj_Class->GetConstructorMethod() ){ 171 171 //////////////////////////////// 172 172 // コンストラクタを呼び出す … … 177 177 178 178 //call constructor 179 op_call(pobj_Class-> ppobj_Method[pobj_Class->ConstructorMemberSubIndex]->psi);179 op_call(pobj_Class->GetConstructorMethod()->psi); 180 180 } 181 181 -
BasicCompiler64/Compile_CallProc.cpp
r50 r51 97 97 98 98 void Opcode_CallProc(char *Parameter,SUBINFO *psi,DWORD dwFlags,char *ObjectName,int RefType){ 99 int i ,i2;99 int i2; 100 100 101 101 if(psi->dwType==SUBTYPE_MACRO){ … … 348 348 op_mov_RM(sizeof(_int64),REG_R11,REG_RCX,0,MOD_BASE); 349 349 350 for(i=0,i2=0;i<pobj_c->iMethodNum;i++){ 351 if(pobj_c->ppobj_Method[i]->psi==psi) break; 352 if(pobj_c->ppobj_Method[i]->psi->bVirtual) i2++; 353 } 350 i2 = pobj_c->GetFuncNumInVtbl( psi ); 354 351 355 352 //call qword ptr[r11+func_index] -
BasicCompiler64/Compile_Func.cpp
r50 r51 172 172 op_mov_RM(sizeof(_int64),REG_R11,REG_RCX,0,MOD_BASE); 173 173 174 int i,i2; 175 for(i=0,i2=0;i<pobj_c->iMethodNum;i++){ 176 if(pobj_c->ppobj_Method[i]->psi==psi) break; 177 if(pobj_c->ppobj_Method[i]->psi->bVirtual) i2++; 178 } 174 int i2 = pobj_c->GetFuncNumInVtbl( psi ); 179 175 180 176 //mov rax,qword ptr[r11+func_index] -
BasicCompiler64/Compile_Object.cpp
r50 r51 198 198 199 199 200 i2=pobj_c->DestructorMemberSubIndex;201 if( i2==-1) return 0;200 CMethod *method = pobj_c->GetDestructorMethod(); 201 if( method == NULL ) return 0; 202 202 203 203 //mov rcx,DestructorProcAddr 204 204 op_mov_RV(sizeof(_int64),REG_RCX,0); 205 205 obp-=sizeof(long); 206 pobj_SubAddrSchedule->add( pobj_c->ppobj_Method[i2]->psi,0);207 pobj_c->ppobj_Method[i2]->psi->bUse=1;206 pobj_SubAddrSchedule->add(method->psi,0); 207 method->psi->bUse=1; 208 208 obp+=sizeof(long); 209 209 -
BasicCompiler64/Compile_ProcOp.cpp
r50 r51 209 209 extern SUBINFO **ppSubHash; 210 210 extern BOOL bDebugCompile; 211 int i3,i4, i5,VarSize,BufferSize;211 int i3,i4,VarSize,BufferSize; 212 212 char temporary[VN_SIZE]; 213 213 … … 466 466 if(psi->ReturnType==DEF_OBJECT && psi->isReturnRef == false){ 467 467 //戻り値用オブジェクトのコンストラクタを呼び出す 468 if( psi->u.Return_pobj_c->ConstructorMemberSubIndex!=-1){468 if( psi->u.Return_pobj_c->GetConstructorMethod() ){ 469 469 sprintf(temporary,"%s.%s()",temp,psi->u.Return_pobj_c->name); 470 470 OpcodeOthers(temporary); … … 517 517 BOOL bThisIsSuperClass; 518 518 if(pobj_CompilingClass->pobj_InheritsClass==0) bThisIsSuperClass=1; 519 else if( pobj_CompilingClass->pobj_InheritsClass->ConstructorMemberSubIndex==-1){519 else if( pobj_CompilingClass->pobj_InheritsClass->GetConstructorMethod() == NULL ){ 520 520 //インターフェイスを継承したときはコンストラクタを持たない 521 521 bThisIsSuperClass=1; … … 552 552 RemoveStringPare(temporary); 553 553 554 i3=pobj_CompilingClass->pobj_InheritsClass->ConstructorMemberSubIndex;555 554 Opcode_CallProc(temporary, 556 pobj_CompilingClass->p pobj_Method[i3]->psi,555 pobj_CompilingClass->pobj_InheritsClass->GetConstructorMethod()->psi, 557 556 0, 558 557 "", … … 561 560 else{ 562 561 //基底クラスのコンストラクタを暗黙的に呼び出す 563 i3=pobj_CompilingClass->pobj_InheritsClass->ConstructorMemberSubIndex;564 562 Opcode_CallProc("", 565 pobj_CompilingClass->p pobj_Method[i3]->psi,563 pobj_CompilingClass->pobj_InheritsClass->GetConstructorMethod()->psi, 566 564 0, 567 565 "", … … 588 586 589 587 if(pMember->TypeInfo.type==DEF_OBJECT && pMember->IsRef() == false){ 590 if(pMember->TypeInfo.u.pobj_Class->ConstructorMemberSubIndex!=-1){591 i5=pMember->TypeInfo.u.pobj_Class->ConstructorMemberSubIndex;592 if( pMember->TypeInfo.u.pobj_Class->ppobj_Method[i5]->psi->RealParmNum==1){ //Thisポインタを第一引数に持ち合わせるため、引数なしの場合はこの値が1になる588 CMethod *method = pMember->TypeInfo.u.pobj_Class->GetConstructorMethod(); 589 if( method ){ 590 if( method->psi->RealParmNum == 1 ){ //Thisポインタを第一引数に持ち合わせるため、引数なしの場合はこの値が1になる 593 591 for(i4=0;i4<MemberObjectNum;i4++){ 594 592 //Thisポインタをrcxにコピー … … 599 597 600 598 //call constructor 601 op_call( pMember->TypeInfo.u.pobj_Class->ppobj_Method[i5]->psi);599 op_call( method->psi ); 602 600 } 603 601 } … … 662 660 基底クラスのデストラクタを呼び出す */ 663 661 664 i3=pobj_CompilingClass->pobj_InheritsClass->DestructorMemberSubIndex;665 if( i3!=-1){662 CMethod *method = pobj_CompilingClass->pobj_InheritsClass->GetDestructorMethod(); 663 if( method ){ 666 664 Opcode_CallProc("", 667 pobj_CompilingClass->ppobj_Method[i3]->psi,665 method->psi, 668 666 0, 669 667 "", … … 689 687 690 688 if(pMember->TypeInfo.type==DEF_OBJECT && pMember->IsRef() == false){ 691 if(pMember->TypeInfo.u.pobj_Class->DestructorMemberSubIndex!=-1){ 689 CMethod *method = pMember->TypeInfo.u.pobj_Class->GetDestructorMethod(); 690 if( method ){ 692 691 for(i4=MemberObjectNum-1;i4>=0;i4--){ 693 692 //Thisポインタをrcxにコピー … … 698 697 699 698 //call destructor 700 i5=pMember->TypeInfo.u.pobj_Class->DestructorMemberSubIndex; 701 op_call(pMember->TypeInfo.u.pobj_Class->ppobj_Method[i5]->psi); 699 op_call(method->psi); 702 700 } 703 701 } -
BasicCompiler64/MakePeHdr.cpp
r42 r51 1059 1059 // プロシージャポインタスケジュール 1060 1060 for(i=0;i<pobj_SubAddrSchedule->num;i++){ 1061 if(pobj_SubAddrSchedule->ppsi[i]->CompileAddress==0 1062 &&pobj_SubAddrSchedule->ppsi[i]->EndOpAddr==0){ 1063 SetError(300,NULL,-1); 1064 } 1065 1061 1066 if(pobj_SubAddrSchedule->pbCall[i]){ 1062 1067 *((long *)(OpBuffer+pobj_SubAddrSchedule->pObpValues[i]))= -
BasicCompiler64/NumOpe.cpp
r49 r51 35 35 36 36 //call constructor 37 op_call(pobj_StringClass-> ppobj_Method[pobj_StringClass->ConstructorMemberSubIndex]->psi);37 op_call(pobj_StringClass->GetConstructorMethod()->psi); 38 38 39 39 int i2; -
BasicCompiler64/OperatorProc.cpp
r50 r51 10 10 //////////////////////////////////////////////// 11 11 12 if(pobj_c->DestructorMemberSubIndex!=-1){ 12 CMethod *method = pobj_c->GetDestructorMethod(); 13 if( method ){ 13 14 //mov rcx,reg 14 15 op_mov_RR(REG_RCX,reg); 15 16 16 17 //call DestructorProcAddr 17 op_call( pobj_c->ppobj_Method[pobj_c->DestructorMemberSubIndex]->psi);18 op_call( method->psi ); 18 19 } 19 20 … … 294 295 295 296 if(bCalcUseHeap){ 296 /*297 //未解放のインスタンスが存在する場合298 //※専用のローカル変数を用意し、メモリリークを回避299 char temporary[VN_SIZE],temp2[VN_SIZE];300 301 302 ////////////////////////////////303 // 一時オブジェクト変数を用意304 ////////////////////////////////305 char szTempVarName[255];306 GetTypeName(CalcType,lpCalcIndex,temp2);307 sprintf(szTempVarName,"_System_strDummy%d",obp);308 wsprintf(temporary,"%s%c%c%s",szTempVarName,1,ESC_AS,temp2);309 InsertDimStatement_ToProcHead(temporary);310 311 RELATIVE_VAR VarRelativeVar;312 int VarType;313 LONG_PTR lpVarIndex;314 if(!GetVarOffsetReadOnly(315 szTempVarName,316 &VarType,317 &VarRelativeVar,318 &lpVarIndex)) return;319 320 321 CClass *pobj_c;322 pobj_c=(CClass *)lpCalcIndex;323 if(pobj_c->DestructorMemberSubIndex!=-1){324 325 //////////////////////////////////////////////////////326 ///// レジスタ資源のバックアップ327 { BACKUP_REGISTER_RESOURCE328 //////////////////////////////////////////////////////329 330 //ループの場合、古い一時オブジェクトのデストラクタを呼ぶ331 332 //rcxに変数アドレスをコピー333 SetVarPtrToReg(REG_RCX,&VarRelativeVar);334 335 //call destructor336 OpBuffer[obp++]=(char)0xE8;337 pobj_SubAddrSchedule->add(pobj_c->ppobj_Method[pobj_c->DestructorMemberSubIndex]->psi,1);338 obp+=sizeof(long);339 340 /////////////////////////////////////////////341 ////// レジスタ資源を復元342 RESTORE_REGISTER_RESOURCE343 }////////////////////////////////////////////344 }345 346 //mov r15,reg347 op_mov_RR(REG_R15,reg);348 349 350 int object_size;351 object_size=GetSizeOfClass((CClass *)lpVarIndex);352 353 //mov rcx,object_size354 op_mov_RV(sizeof(_int64),REG_RCX,object_size);355 356 //rdiに変数アドレスをコピー357 SetVarPtrToReg(REG_RDI,&VarRelativeVar);358 359 //mov rsi,reg360 op_mov_RR(REG_RSI,reg);361 362 //mov r14,rdi363 op_mov_RR(REG_R14,REG_RDI);364 pobj_BlockReg->lock(REG_R14);365 366 //rep movs byte ptr[rdi],byte ptr[rsi]367 op_rep_movs(sizeof(BYTE));368 369 //////////////////////////////////////////////////////370 ///// レジスタ資源のバックアップ371 { BACKUP_REGISTER_RESOURCE372 //////////////////////////////////////////////////////373 374 //mov rcx,r15375 op_mov_RR(REG_RCX,REG_R15);376 377 //call free378 extern SUBINFO *pSub_free;379 OpBuffer[obp++]=(char)0xE8;380 pobj_SubAddrSchedule->add(pSub_free,1);381 obp+=sizeof(long);382 383 /////////////////////////////////////////////384 ////// レジスタ資源を復元385 RESTORE_REGISTER_RESOURCE386 }////////////////////////////////////////////387 388 389 //mov reg,r14390 op_mov_RR(reg,REG_R14);391 392 pobj_BlockReg->unlock(REG_R14);393 */394 395 297 //未解放のインスタンスが存在する旨を示す警告 396 298 SetError(-105,NULL,cp); 397 398 299 } 399 300
Note:
See TracChangeset
for help on using the changeset viewer.