Changeset 63 in dev
- Timestamp:
- Feb 23, 2007, 2:12:26 AM (18 years ago)
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler32/CParameter.cpp
r59 r63 130 130 131 131 void CParameter::SetObjectParameter(CClass *pobj_Class,LPSTR Parameter){ 132 int object_size; 133 object_size=GetSizeOfClass(pobj_Class); 132 int object_size = pobj_Class->GetSize(); 134 133 135 134 //push object_size -
BasicCompiler32/Compile_CallProc.cpp
r51 r63 259 259 ////////////////////////////////////////////////////// 260 260 261 int object_size; 262 object_size=GetSizeOfClass(psi->u.Return_pobj_c); 261 int object_size = psi->u.Return_pobj_c->GetSize(); 263 262 264 263 //push object_size -
BasicCompiler32/Compile_ProcOp.cpp
r55 r63 515 515 516 516 //実体クラスを持つメンバのコンストラクタ(引数有りを除く)を呼び出す 517 int offset;518 int MemberTypeSize;519 int MemberObjectNum;520 if(pobj_CompilingClass->vtbl_num) offset=PTR_SIZE;521 else offset=0;522 517 for(i3=0;i3<pobj_CompilingClass->iMemberNum;i3++){ 523 518 CMember *pMember = pobj_CompilingClass->ppobj_Member[i3]; 524 MemberTypeSize=519 int MemberTypeSize= 525 520 GetTypeSize(pMember->TypeInfo.type, 526 521 pMember->TypeInfo.u.lpIndex); 527 522 528 MemberObjectNum=523 int MemberObjectNum= 529 524 JumpSubScripts(pMember->SubScripts); 530 525 531 offset=GetSizeOfClassMember(pobj_CompilingClass,pMember->name,NULL);526 int offset = pobj_CompilingClass->GetMemberOffset( pMember->name, NULL ); 532 527 533 528 if(pMember->TypeInfo.type==DEF_OBJECT && pMember->IsRef() == false){ … … 561 556 pobj_CompilingClass->IsAbstract()==false){ 562 557 //関数テーブルに値をセット 563 offset=pobj_CompilingClass->GetVtblGlobalOffset();558 int offset = (int)pobj_CompilingClass->GetVtblGlobalOffset(); 564 559 565 560 //mov eax,offset -
BasicCompiler32/Compile_Set_Var.cpp
r62 r63 46 46 //※コピーを行う 47 47 48 int object_size; 49 object_size=GetSizeOfClass((CClass *)lpVarIndex); 48 int object_size = pVarClass->GetSize(); 50 49 51 50 //mov ecx,object_size -
BasicCompiler32/Compile_Var.cpp
r62 r63 25 25 *pType=MAKE_PTR_TYPE(NATURAL_TYPE(*pType),PTR_LEVEL(*pType)-1); 26 26 if((*pType)==DEF_OBJECT){ 27 CClass *pClass = (CClass *)lpIndex; 28 int objsize = pClass->GetSize(); 29 27 30 //imul ebx,objsize 28 31 OpBuffer[obp++]=(char)0x69; 29 32 OpBuffer[obp++]=(char)0xDB; 30 *((long *)(OpBuffer+obp))= GetSizeOfClassMember((CClass *)lpIndex,NULL,NULL);33 *((long *)(OpBuffer+obp))=objsize; 31 34 obp+=sizeof(long); 32 35 } … … 158 161 } 159 162 BOOL GetMemberOffset(bool isErrorEnabled, bool isWriteAccess, CClass *pobj_c, char *member, int *pType, RELATIVE_VAR *pRelativeVar, LONG_PTR *plpNestIndex, BOOL bPrivateAccess){ 160 int i ,offset;163 int i; 161 164 162 165 //クラス、配列の構成要素を解析する … … 173 176 //////////////////////////// 174 177 175 offset=GetSizeOfClassMember(pobj_c,VarName,&i);178 int offset=pobj_c->GetMemberOffset( VarName, &i ); 176 179 if(i==pobj_c->iMemberNum){ 177 180 if(isErrorEnabled) SetError(103,VarName,cp); … … 789 792 i=GetOneParameter(InitBuf,i,temporary); 790 793 791 i3= GetSizeOfClassMember(pobj_c,pobj_c->ppobj_Member[i2]->name,NULL);794 i3=pobj_c->GetMemberOffset( pobj_c->ppobj_Member[i2]->name, NULL ); 792 795 793 796 if(!SetInitGlobalData(offset+i3, … … 922 925 i=GetOneParameter(InitBuf,i,temporary); 923 926 924 i3 =GetSizeOfClassMember(pobj_c,pobj_c->ppobj_Member[i2]->name,NULL);927 i3 = pobj_c->GetMemberOffset( pobj_c->ppobj_Member[i2]->name, NULL ); 925 928 926 929 if(!InitLocalVar(offset+i3, -
BasicCompiler32/NumOpe.cpp
r56 r63 75 75 76 76 extern CClass *pobj_StringClass; 77 int object_size; 78 object_size=GetSizeOfClass(pobj_StringClass); 77 int object_size = pobj_StringClass->GetSize(); 79 78 80 79 //push object_size -
BasicCompiler32/OperatorProc.cpp
r51 r63 125 125 ////////////////////////////////////////////////////// 126 126 127 int object_size; 128 object_size=GetSizeOfClass(psi->u.Return_pobj_c); 127 int object_size = psi->u.Return_pobj_c->GetSize(); 129 128 130 129 //push object_size -
BasicCompiler32/VarList.cpp
r55 r63 165 165 } 166 166 167 LONG_PTR offset; 168 offset=GetSizeOfClassMember(pobj_c,pobj_c->ppobj_Member[i]->name,&i2); 167 LONG_PTR offset = pobj_c->GetMemberOffset( pobj_c->ppobj_Member[i]->name, &i2 ); 169 168 170 169 if(pobj_c->ppobj_Member[i]->SubScripts[0]!=-1){ … … 423 422 424 423 for(i=0;i<psi->pobj_ParentClass->iMemberNum;i++){ 425 offset =GetSizeOfClassMember(psi->pobj_ParentClass,psi->pobj_ParentClass->ppobj_Member[i]->name,&i2);424 offset = psi->pobj_ParentClass->GetMemberOffset( psi->pobj_ParentClass->ppobj_Member[i]->name, &i2 ); 426 425 427 426 if(psi->pobj_ParentClass->ppobj_Member[i]->SubScripts[0]!=-1){ -
BasicCompiler32/WatchList.cpp
r62 r63 78 78 if(PTR_LEVEL(*pType)){ 79 79 *pType=MAKE_PTR_TYPE(NATURAL_TYPE(*pType),PTR_LEVEL(*pType)-1); 80 if((*pType)==DEF_OBJECT) 81 array_num*=GetSizeOfClass((CClass *)lpIndex); 82 else 83 array_num*=GetTypeSize(*pType,-1); 80 if((*pType)==DEF_OBJECT){ 81 CClass *pClass = (CClass *)lpIndex; 82 array_num *= pClass->GetSize(); 83 } 84 else{ 85 array_num *= GetTypeSize(*pType,-1); 86 } 84 87 } 85 88 else{ … … 100 103 101 104 BOOL Debugging_GetMember(CClass *pobj_c,char *member,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpNestIndex,BOOL bPrivateAccess){ 102 int i,i2 ,offset;105 int i,i2; 103 106 104 107 //直接参照に切り替え … … 120 123 //////////////////////////// 121 124 122 offset=GetSizeOfClassMember(pobj_c,VarName,&i);125 int offset = pobj_c->GetMemberOffset( VarName, &i ); 123 126 if(i==pobj_c->iMemberNum) return 0; 124 127 -
BasicCompiler64/CParameter.cpp
r59 r63 118 118 ////////////////////////////////////////////////////// 119 119 120 int object_size; 121 object_size=GetSizeOfClass(pobj_Class); 120 int object_size = pobj_Class->GetSize(); 122 121 123 122 //mov rcx,object_size -
BasicCompiler64/Compile_CallProc.cpp
r51 r63 267 267 ////////////////////////////////////////////////////// 268 268 269 int object_size; 270 object_size=GetSizeOfClass(psi->u.Return_pobj_c); 269 int object_size = psi->u.Return_pobj_c->GetSize(); 271 270 272 271 //mov rcx,object_size -
BasicCompiler64/Compile_ProcOp.cpp
r51 r63 569 569 570 570 //実体クラスを持つメンバのコンストラクタ(引数有りを除く)を呼び出す 571 int offset;572 int MemberTypeSize;573 int MemberObjectNum;574 if(pobj_CompilingClass->vtbl_num) offset=PTR_SIZE;575 else offset=0;576 571 for(i3=0;i3<pobj_CompilingClass->iMemberNum;i3++){ 577 572 CMember *pMember = pobj_CompilingClass->ppobj_Member[i3]; 578 MemberTypeSize=573 int MemberTypeSize= 579 574 GetTypeSize(pMember->TypeInfo.type, 580 575 pMember->TypeInfo.u.lpIndex); 581 576 582 MemberObjectNum=577 int MemberObjectNum= 583 578 JumpSubScripts(pMember->SubScripts); 584 579 585 offset=GetSizeOfClassMember(pobj_CompilingClass,pMember->name,NULL);580 int offset = pobj_CompilingClass->GetMemberOffset( pMember->name, NULL ); 586 581 587 582 if(pMember->TypeInfo.type==DEF_OBJECT && pMember->IsRef() == false){ … … 608 603 pobj_CompilingClass->IsAbstract()==false){ 609 604 //関数テーブルに値をセット 610 offset=(int)pobj_CompilingClass->GetVtblGlobalOffset();605 int offset = (int)pobj_CompilingClass->GetVtblGlobalOffset(); 611 606 612 607 //mov rax,offset … … 672 667 //実体クラスを持つメンバのデストラクタを呼び出す 673 668 //※コンストラクタと逆順序で呼び出す 674 int offset;675 int MemberTypeSize;676 int MemberObjectNum;677 669 for(i3=pobj_CompilingClass->iMemberNum-1;i3>=0;i3--){ 678 670 CMember *pMember = pobj_CompilingClass->ppobj_Member[i3]; 679 MemberTypeSize=671 int MemberTypeSize= 680 672 GetTypeSize(pMember->TypeInfo.type, 681 673 pMember->TypeInfo.u.lpIndex); 682 674 683 MemberObjectNum=675 int MemberObjectNum= 684 676 JumpSubScripts(pMember->SubScripts); 685 677 686 offset=GetSizeOfClassMember(pobj_CompilingClass,pMember->name,NULL);678 int offset = pobj_CompilingClass->GetMemberOffset( pMember->name, NULL ); 687 679 688 680 if(pMember->TypeInfo.type==DEF_OBJECT && pMember->IsRef() == false){ -
BasicCompiler64/Compile_Set_Var.cpp
r62 r63 93 93 op_mov_RR(REG_RDI,VarReg); 94 94 95 int object_size = GetSizeOfClass((CClass *)lpVarIndex); 95 CClass *pClass = (CClass *)lpVarIndex; 96 int object_size = pClass->GetSize(); 96 97 97 98 //mov rcx,object_size -
BasicCompiler64/Compile_Var.cpp
r62 r63 43 43 *pType=MAKE_PTR_TYPE(NATURAL_TYPE(*pType),PTR_LEVEL(*pType)-1); 44 44 if((*pType)==DEF_OBJECT){ 45 CClass *pClass = (CClass *)lpIndex; 45 46 //imul reg,objsize 46 op_imul_value( sizeof(_int64),reg,GetSizeOfClassMember((CClass *)lpIndex,NULL,NULL));47 op_imul_value( sizeof(_int64), reg, pClass->GetSize() ); 47 48 } 48 49 else{ … … 180 181 } 181 182 BOOL GetMemberOffset(bool isErrorEnabled, bool isWriteAccess, CClass *pobj_c, char *member, int *pType, RELATIVE_VAR *pRelativeVar, LONG_PTR *plpNestIndex, BOOL bPrivateAccess){ 182 int i ,offset;183 int i; 183 184 184 185 … … 200 201 //////////////////////////// 201 202 202 offset=GetSizeOfClassMember(pobj_c,VarName,&i);203 int offset = pobj_c->GetMemberOffset( VarName, &i ); 203 204 if(i==pobj_c->iMemberNum){ 204 205 if(isErrorEnabled) SetError(103,VarName,cp); … … 821 822 i=GetOneParameter(InitBuf,i,temporary); 822 823 823 i3= GetSizeOfClassMember(pobj_c,pobj_c->ppobj_Member[i2]->name,NULL);824 i3=pobj_c->GetMemberOffset( pobj_c->ppobj_Member[i2]->name, NULL ); 824 825 825 826 if(!SetInitGlobalData(offset+i3, … … 959 960 i=GetOneParameter(InitBuf,i,temporary); 960 961 961 i3= GetSizeOfClassMember(pobj_c,pobj_c->ppobj_Member[i2]->name,NULL);962 i3=pobj_c->GetMemberOffset( pobj_c->ppobj_Member[i2]->name, NULL ); 962 963 963 964 if(!InitLocalVar(offset+i3, -
BasicCompiler64/NumOpe.cpp
r56 r63 15 15 16 16 extern CClass *pobj_StringClass; 17 int object_size; 18 object_size=GetSizeOfClass(pobj_StringClass); 17 int object_size = pobj_StringClass->GetSize(); 19 18 20 19 //mov rcx,object_size -
BasicCompiler64/OperatorProc.cpp
r51 r63 137 137 ////////////////////////////////////////////////////// 138 138 139 int object_size; 140 object_size=GetSizeOfClass(psi->u.Return_pobj_c); 139 int object_size = psi->u.Return_pobj_c->GetSize(); 141 140 142 141 //mov rcx,object_size -
BasicCompiler64/WatchList.cpp
r62 r63 78 78 if(PTR_LEVEL(*pType)){ 79 79 *pType=MAKE_PTR_TYPE(NATURAL_TYPE(*pType),PTR_LEVEL(*pType)-1); 80 if((*pType)==DEF_OBJECT) 81 array_num*=GetSizeOfClassMember((CClass *)lpIndex,NULL,NULL); 82 else 83 array_num*=GetTypeSize(*pType,-1); 80 if((*pType)==DEF_OBJECT){ 81 CClass *pClass = (CClass *)lpIndex; 82 array_num *= pClass->GetSize(); 83 } 84 else{ 85 array_num *= GetTypeSize(*pType,-1); 86 } 84 87 } 85 88 else{ … … 100 103 101 104 BOOL Debugging_GetMember(CClass *pobj_c,char *member,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpNestIndex,BOOL bPrivateAccess){ 102 int i,i2 ,offset;105 int i,i2; 103 106 104 107 //直接参照に切り替え … … 120 123 //////////////////////////// 121 124 122 offset=GetSizeOfClassMember(pobj_c,VarName,&i);125 int offset = pobj_c->GetMemberOffset( VarName, &i ); 123 126 if(i==pobj_c->iMemberNum) return 0; 124 127 -
BasicCompiler64/varlist.cpp
r55 r63 168 168 169 169 LONG_PTR offset; 170 offset= GetSizeOfClassMember(pobj_c,pobj_c->ppobj_Member[i]->name,&i2);170 offset=pobj_c->GetMemberOffset( pobj_c->ppobj_Member[i]->name, &i2 ); 171 171 172 172 if(pobj_c->ppobj_Member[i]->SubScripts[0]!=-1){ … … 428 428 429 429 for(i=0;i<psi->pobj_ParentClass->iMemberNum;i++){ 430 offset= GetSizeOfClassMember(psi->pobj_ParentClass,psi->pobj_ParentClass->ppobj_Member[i]->name,&i2);430 offset=psi->pobj_ParentClass->GetMemberOffset( psi->pobj_ParentClass->ppobj_Member[i]->name,&i2); 431 431 432 432 if(psi->pobj_ParentClass->ppobj_Member[i]->SubScripts[0]!=-1){ -
BasicCompiler_Common/Class.cpp
r62 r63 409 409 return methods[DestructorMemberSubIndex]; 410 410 } 411 412 //サイズを取得 413 int CClass::GetSize() const 414 { 415 return GetMemberOffset( NULL, NULL ); 416 } 417 418 //メンバのオフセットを取得 419 int CClass::GetMemberOffset( const char *memberName, int *pMemberNum ) const 420 { 421 int i,i2,offset; 422 423 //仮想関数が存在する場合は関数リストへのポインタのサイズを追加 424 if(vtbl_num) offset=PTR_SIZE; 425 else offset=0; 426 427 int alignment; 428 if(iAlign) alignment=iAlign; 429 else alignment=1; 430 431 int iMaxAlign=0; 432 for(i=0;i<iMemberNum;i++){ 433 CMember *pMember = ppobj_Member[i]; 434 435 i2 = pMember->GetSize(); 436 437 //アラインメントを算出 438 int member_size; 439 if(pMember->TypeInfo.type==DEF_OBJECT){ 440 //メンバクラスのアラインメントを取得 441 member_size=pMember->TypeInfo.u.pobj_Class->GetAlignment(); 442 } 443 else{ 444 //メンバサイズを取得 445 member_size=i2; 446 } 447 if(iMaxAlign<member_size) iMaxAlign=member_size; 448 449 //アラインメントを考慮 450 if(iAlign&&iAlign<member_size){ 451 if(offset%alignment) offset+=alignment-(offset%alignment); 452 } 453 else{ 454 if(alignment<member_size) alignment=member_size; 455 456 if(member_size==0){ 457 //メンバを持たないクラス 458 //※何もしない(オフセットの計算をしない) 459 } 460 else{ 461 if(offset%member_size) offset+=member_size-(offset%member_size); 462 } 463 } 464 465 if(memberName){ 466 //メンバ指定がある場合は、オフセットを返す 467 if(lstrcmp(pMember->name,memberName)==0){ 468 if(pMemberNum) *pMemberNum=i; 469 return offset; 470 } 471 } 472 473 //配列を考慮したメンバサイズを取得 474 member_size=i2 * JumpSubScripts(pMember->SubScripts); 475 476 //メンバサイズを加算 477 offset+= member_size; 478 } 479 480 if(iMaxAlign<alignment) alignment=iMaxAlign; 481 482 //アラインメントを考慮 483 if(alignment){ 484 if(offset%alignment) offset+=alignment-(offset%alignment); 485 } 486 487 if(pMemberNum) *pMemberNum=i; 488 return offset; 489 } 490 491 int CClass::GetAlignment() const 492 { 493 int i; 494 int alignment,member_size; 495 496 if(vtbl_num) alignment=PTR_SIZE; 497 else alignment=0; 498 499 for(i=0;i<iMemberNum;i++){ 500 CMember *pMember = ppobj_Member[i]; 501 502 if(pMember->TypeInfo.type==DEF_OBJECT && pMember->IsRef() == false){ 503 //メンバクラスのアラインメントを取得 504 member_size=pMember->TypeInfo.u.pobj_Class->GetAlignment(); 505 } 506 else{ 507 //メンバサイズを取得 508 member_size = pMember->GetSize(); 509 } 510 511 //アラインメントをセット 512 if(alignment<member_size) alignment=member_size; 513 } 514 515 if(alignment==0) return 0; 516 517 if(iAlign) alignment=iAlign; 518 519 return alignment; 520 } 521 411 522 412 523 -
BasicCompiler_Common/Class.h
r59 r63 136 136 CMethod *GetDestructorMethod() const; 137 137 138 // メンバの総合サイズを取得 139 int GetSize() const; 140 141 // メンバのオフセットを取得 142 int GetMemberOffset( const char *memberName, int *pMemberNum ) const; 143 144 private: 145 // アラインメント値を取得 146 int GetAlignment() const; 147 138 148 139 149 //vtbl -
BasicCompiler_Common/Object.cpp
r50 r63 8 8 9 9 extern HANDLE hHeap; 10 11 int GetAlignment(CClass *pobj_c){12 int i;13 int alignment,member_size;14 15 if(pobj_c->vtbl_num) alignment=PTR_SIZE;16 else alignment=0;17 18 for(i=0;i<pobj_c->iMemberNum;i++){19 CMember *pMember = pobj_c->ppobj_Member[i];20 21 if(pMember->TypeInfo.type==DEF_OBJECT && pMember->IsRef() == false){22 //メンバクラスのアラインメントを取得23 member_size=GetAlignment(pMember->TypeInfo.u.pobj_Class);24 }25 else{26 //メンバサイズを取得27 member_size = pMember->GetSize();28 }29 30 //アラインメントをセット31 if(alignment<member_size) alignment=member_size;32 }33 34 if(alignment==0) return 0;35 36 if(pobj_c->iAlign) alignment=pobj_c->iAlign;37 38 return alignment;39 }40 int GetSizeOfClassMember(CClass *pobj_c,char *pMemberName,int *pMemberNum){41 int i,i2,offset;42 43 //仮想関数が存在する場合は関数リストへのポインタのサイズを追加44 if(pobj_c->vtbl_num) offset=PTR_SIZE;45 else offset=0;46 47 int alignment;48 if(pobj_c->iAlign) alignment=pobj_c->iAlign;49 else alignment=1;50 51 int iMaxAlign=0;52 for(i=0;i<pobj_c->iMemberNum;i++){53 CMember *pMember = pobj_c->ppobj_Member[i];54 55 i2 = pMember->GetSize();56 57 //アラインメントを算出58 int member_size;59 if(pMember->TypeInfo.type==DEF_OBJECT){60 //メンバクラスのアラインメントを取得61 member_size=GetAlignment(pMember->TypeInfo.u.pobj_Class);62 }63 else{64 //メンバサイズを取得65 member_size=i2;66 }67 if(iMaxAlign<member_size) iMaxAlign=member_size;68 69 //アラインメントを考慮70 if(pobj_c->iAlign&&pobj_c->iAlign<member_size){71 if(offset%alignment) offset+=alignment-(offset%alignment);72 }73 else{74 if(alignment<member_size) alignment=member_size;75 76 if(member_size==0){77 //メンバを持たないクラス78 //※何もしない(オフセットの計算をしない)79 }80 else{81 if(offset%member_size) offset+=member_size-(offset%member_size);82 }83 }84 85 if(pMemberName){86 //メンバ指定がある場合は、オフセットを返す87 if(lstrcmp(pMember->name,pMemberName)==0){88 if(pMemberNum) *pMemberNum=i;89 return offset;90 }91 }92 93 //配列を考慮したメンバサイズを取得94 member_size=i2 * JumpSubScripts(pMember->SubScripts);95 96 //メンバサイズを加算97 offset+= member_size;98 }99 100 if(iMaxAlign<alignment) alignment=iMaxAlign;101 102 //アラインメントを考慮103 if(alignment){104 if(offset%alignment) offset+=alignment-(offset%alignment);105 }106 107 if(pMemberNum) *pMemberNum=i;108 return offset;109 }110 int GetSizeOfClass(CClass *pobj_c){111 return GetSizeOfClassMember(pobj_c,0,0);112 }113 114 10 115 11 void CallConstructor(char *ObjectName,int *SubScripts,TYPEINFO &TypeInfo,char *Parameter){ -
BasicCompiler_Common/Variable.cpp
r62 r63 161 161 pobj_c=(CClass *)lpIndex; 162 162 if(!pobj_c) return 0; 163 return GetSizeOfClass(pobj_c);163 return pobj_c->GetSize(); 164 164 } 165 165 else{ -
BasicCompiler_Common/common.h
r60 r63 426 426 427 427 //Object.cpp 428 int GetSizeOfClassMember(CClass *pobj_c,char *pMemberName,int *pMemberNum);429 int GetSizeOfClass(CClass *pobj_c);430 428 void AddClassName(char *Parameter,int NowLine); 431 429 void CallConstructor(char *VarName,int *SubScripts,TYPEINFO &TypeInfo,char *Parameter);
Note:
See TracChangeset
for help on using the changeset viewer.