Changeset 75 in dev for BasicCompiler_Common/DebugMiddleFile.cpp
- Timestamp:
- Mar 20, 2007, 4:36:16 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler_Common/DebugMiddleFile.cpp
r73 r75 10 10 11 11 12 void SetLpIndex_DebugFile(char *buffer,int *p, int type,LONG_PTR lpIndex){13 if(NATURAL_TYPE(type )==DEF_OBJECT || NATURAL_TYPE(type)==DEF_STRUCT){14 lstrcpy(buffer+(*p), ((CClass *)lpIndex)->name);12 void SetLpIndex_DebugFile(char *buffer,int *p,const Type &type){ 13 if(NATURAL_TYPE(type.GetBasicType())==DEF_OBJECT || NATURAL_TYPE(type.GetBasicType())==DEF_STRUCT){ 14 lstrcpy(buffer+(*p),type.GetClass().name); 15 15 (*p)+=lstrlen(buffer+(*p))+1; 16 16 } 17 17 else{ 18 *(LONG_PTR *)(buffer+(*p))= lpIndex;18 *(LONG_PTR *)(buffer+(*p))=type.GetIndex(); 19 19 (*p)+=sizeof(LONG_PTR); 20 20 } … … 22 22 23 23 24 void GetLpIndex_DebugFile(char *buffer,int *p, int type,LONG_PTR *plpIndex){25 if(NATURAL_TYPE(type )==DEF_OBJECT || NATURAL_TYPE(type)==DEF_STRUCT){24 void GetLpIndex_DebugFile(char *buffer,int *p,Type &type){ 25 if(NATURAL_TYPE(type.GetBasicType())==DEF_OBJECT || NATURAL_TYPE(type.GetBasicType())==DEF_STRUCT){ 26 26 char szClassName[VN_SIZE]; 27 27 lstrcpy(szClassName,buffer+(*p)); 28 28 (*p)+=lstrlen(buffer+(*p))+1; 29 29 30 *plpIndex=(LONG_PTR)pobj_DBClass->check(szClassName);30 type.SetIndex( (LONG_PTR)pobj_DBClass->check(szClassName) ); 31 31 } 32 32 else{ 33 *plpIndex=*(LONG_PTR *)(buffer+(*p));33 type.SetIndex( *(LONG_PTR *)(buffer+(*p)) ); 34 34 (*p)+=sizeof(LONG_PTR); 35 35 } … … 49 49 } 50 50 void CDebugSection::make(void){ 51 extern VARIABLE *GlobalVar;52 extern int MaxGlobalVarNum;53 51 extern INCLUDEFILEINFO IncludeFileInfo; 54 52 int i2,i3,i4,i5,BufferSize; … … 160 158 161 159 //グローバル変数情報 162 *(long *)(buffer+i2)=MaxGlobalVarNum; 163 i2+=sizeof(long); 164 for(i3=0;i3<MaxGlobalVarNum;i3++){ 165 VARIABLE *pVar=&GlobalVar[i3]; 166 160 *(long *)(buffer+i2)=(int)::globalVars.size(); 161 i2+=sizeof(long); 162 foreach( Variable *pVar, ::globalVars ){ 167 163 //変数名 168 lstrcpy(buffer+i2,pVar-> name);164 lstrcpy(buffer+i2,pVar->GetName().c_str()); 169 165 i2+=lstrlen(buffer+i2)+1; 170 166 171 167 //型 172 *(long *)(buffer+i2)=pVar-> type;168 *(long *)(buffer+i2)=pVar->GetBasicType(); 173 169 i2+=sizeof(long); 174 170 175 171 //型の拡張情報 176 SetLpIndex_DebugFile(buffer,&i2, pVar->type,pVar->u.index);177 178 buffer[i2++] =(char)pVar->fRef;179 180 buffer[i2++] =(char)pVar->bArray;181 182 if(pVar-> bArray){183 for(i 4=0;;i4++){184 *(long *)(buffer+i2)=pVar-> SubScripts[i4];172 SetLpIndex_DebugFile(buffer,&i2,*pVar); 173 174 buffer[i2++] = pVar->IsRef() ? 1 : 0; 175 176 buffer[i2++] = pVar->IsArray() ? 1 : 0; 177 178 if(pVar->IsArray()){ 179 for(i5=0;;i5++){ 180 *(long *)(buffer+i2)=pVar->GetSubScriptsPtr()[i5]; 185 181 i2+=sizeof(long); 186 if(pVar-> SubScripts[i4]==-1) break;182 if(pVar->GetSubScriptsPtr()[i5]==-1) break; 187 183 } 188 184 } … … 213 209 214 210 //プロシージャ情報 215 extern SubInfo**ppSubHash;211 extern UserProc **ppSubHash; 216 212 extern int SubNum; 217 SubInfo *psi;213 UserProc *pUserProc; 218 214 *(long *)(buffer+i2)=SubNum; 219 215 i2+=sizeof(long); 220 216 for(i3=0;i3<MAX_HASH;i3++){ 221 p si=ppSubHash[i3];222 while(p si){223 if(p si->pobj_ParentClass){224 lstrcpy(buffer+i2,p si->pobj_ParentClass->name);217 pUserProc=ppSubHash[i3]; 218 while(pUserProc){ 219 if(pUserProc->GetParentClassPtr()){ 220 lstrcpy(buffer+i2,pUserProc->GetParentClassPtr()->name); 225 221 i2+=lstrlen(buffer+i2)+1; 226 222 } … … 231 227 232 228 //ID 233 *(long *)(buffer+i2)=p si->id;229 *(long *)(buffer+i2)=pUserProc->id; 234 230 i2+=sizeof(long); 235 231 236 232 //関数名 237 lstrcpy(buffer+i2,p si->name);233 lstrcpy(buffer+i2,pUserProc->GetName().c_str()); 238 234 i2+=lstrlen(buffer+i2)+1; 239 235 240 *(long *)(buffer+i2)=psi->CompileAddress; 241 i2+=sizeof(long); 242 *(long *)(buffer+i2)=psi->EndOpAddr; 243 i2+=sizeof(long); 244 245 *(long *)(buffer+i2)=psi->bVirtual; 236 *(long *)(buffer+i2)=pUserProc->beginOpAddress; 237 i2+=sizeof(long); 238 *(long *)(buffer+i2)=pUserProc->endOpAddress; 246 239 i2+=sizeof(long); 247 240 248 241 //ローカル変数情報 249 *(long *)(buffer+i2)= psi->VarNum;242 *(long *)(buffer+i2)=(int)pUserProc->localVars.size(); 250 243 i2+=sizeof(long); 251 244 … … 256 249 } 257 250 258 for(i4=0;i4<psi->VarNum;i4++){ 259 VARIABLE *pVar=&psi->pVar[i4]; 260 lstrcpy(buffer+i2,pVar->name); 251 foreach( Variable *pVar, pUserProc->localVars ){ 252 lstrcpy(buffer+i2,pVar->GetName().c_str()); 261 253 i2+=lstrlen(buffer+i2)+1; 262 254 263 255 //型 264 *(long *)(buffer+i2)=pVar-> type;256 *(long *)(buffer+i2)=pVar->GetBasicType(); 265 257 i2+=sizeof(long); 266 258 267 259 //型の拡張情報 268 SetLpIndex_DebugFile(buffer,&i2, pVar->type,pVar->u.index);260 SetLpIndex_DebugFile(buffer,&i2,*pVar); 269 261 270 262 //参照型パラメータかどうか 271 buffer[i2++] =(char)pVar->fRef;263 buffer[i2++] = pVar->IsRef() ? 1 : 0; 272 264 273 265 //配列かどうか 274 buffer[i2++] =(char)pVar->bArray;266 buffer[i2++] = pVar->IsArray() ? 1 : 0; 275 267 276 268 //配列要素 277 if(pVar-> bArray){269 if(pVar->IsArray()){ 278 270 for(i5=0;;i5++){ 279 *(long *)(buffer+i2)=pVar-> SubScripts[i5];271 *(long *)(buffer+i2)=pVar->GetSubScriptsPtr()[i5]; 280 272 i2+=sizeof(long); 281 if(pVar-> SubScripts[i5]==-1) break;273 if(pVar->GetSubScriptsPtr()[i5]==-1) break; 282 274 } 283 275 } 284 else pVar->SubScripts[0]=-1;285 276 286 277 //レキシカルスコープ情報 … … 306 297 } 307 298 308 p si=psi->pNextData;299 pUserProc=pUserProc->pNextData; 309 300 } 310 301 } … … 347 338 348 339 //型 349 *(long *)(buffer+i2)=pobj_c->ppobj_Member[i4]-> TypeInfo.type;340 *(long *)(buffer+i2)=pobj_c->ppobj_Member[i4]->GetBasicType(); 350 341 i2+=sizeof(long); 351 342 352 343 //型の拡張情報 353 SetLpIndex_DebugFile(buffer,&i2, pobj_c->ppobj_Member[i4]->TypeInfo.type,pobj_c->ppobj_Member[i4]->TypeInfo.u.lpIndex);344 SetLpIndex_DebugFile(buffer,&i2,*pobj_c->ppobj_Member[i4]); 354 345 355 346 *(long *)(buffer+i2)=pobj_c->ppobj_Member[i4]->dwAccess; … … 377 368 i2+=lstrlen(buffer+i2)+1; 378 369 } 379 lstrcpy(buffer+i2,method->p si->name);370 lstrcpy(buffer+i2,method->pUserProc->GetName().c_str()); 380 371 i2+=lstrlen(buffer+i2)+1; 381 372 } … … 392 383 393 384 //型 394 *(long *)(buffer+i2)=member-> TypeInfo.type;385 *(long *)(buffer+i2)=member->GetBasicType(); 395 386 i2+=sizeof(long); 396 387 397 388 //型の拡張情報 398 SetLpIndex_DebugFile(buffer,&i2, member->TypeInfo.type,member->TypeInfo.u.lpIndex);389 SetLpIndex_DebugFile(buffer,&i2,*member); 399 390 400 391 *(long *)(buffer+i2)=member->dwAccess; … … 540 531 541 532 //グローバル変数情報 542 MaxGlobalVarNum=*(long *)(buffer+i2); 543 i2+=sizeof(long); 544 GlobalVar=(VARIABLE *)HeapAlloc(hHeap,0,MaxGlobalVarNum*sizeof(VARIABLE)+1); 545 for(i3=0;i3<MaxGlobalVarNum;i3++){ 546 VARIABLE *pVar=&GlobalVar[i3]; 533 globalVars.clear(); 534 int maxGlobalVars=*(long *)(buffer+i2); 535 i2+=sizeof(long); 536 for(i3=0;i3<maxGlobalVars;i3++){ 547 537 548 538 //変数名 549 lstrcpy(pVar->name,buffer+i2); 550 i2+=lstrlen(buffer+i2)+1; 551 552 pVar->type=*(long *)(buffer+i2); 553 i2+=sizeof(long); 554 555 GetLpIndex_DebugFile(buffer,&i2,pVar->type,&pVar->u.index); 556 557 pVar->fRef=(long)buffer[i2++]; 558 559 pVar->bArray=(long)buffer[i2++]; 560 if(pVar->bArray){ 539 char *name = buffer+i2; 540 i2+=lstrlen(buffer+i2)+1; 541 542 int basicType = *(long *)(buffer+i2); 543 i2+=sizeof(long); 544 545 Type type( basicType ); 546 GetLpIndex_DebugFile(buffer,&i2,type); 547 548 bool isRef = (buffer[i2++]) ? true:false; 549 550 bool isArray = (buffer[i2++]) ? true:false; 551 552 Variable *pVar = new Variable( name, type, false, isRef ); 553 554 if(isArray){ 555 int SubScripts[MAX_ARRAYDIM]; 561 556 for(i4=0;;i4++){ 562 pVar->SubScripts[i4]=*(long *)(buffer+i2);557 SubScripts[i4]=*(long *)(buffer+i2); 563 558 i2+=sizeof(long); 564 559 565 if(pVar->SubScripts[i4]==-1) break; 566 } 560 if(SubScripts[i4]==-1) break; 561 } 562 563 pVar->SetArray( SubScripts ); 567 564 } 568 565 … … 578 575 pVar->offset=*(long *)(buffer+i2); 579 576 i2+=sizeof(long); 577 578 //変数を追加 579 globalVars.push_back( pVar ); 580 580 } 581 581 … … 585 585 586 586 //プロシージャ情報 587 SubInfo *psi;587 UserProc *pUserProc; 588 588 SubNum=*(long *)(buffer+i2); 589 589 i2+=sizeof(long); 590 ppSubHash=(SubInfo **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(SubInfo *)); 591 for(i3=0;i3<SubNum;i3++){ 592 psi = new SubInfo(); 593 psi->pNextData=0; 594 590 ppSubHash=(UserProc **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(UserProc *)); 591 for(int i6=0;i6<SubNum;i6++){ 595 592 char szParentClassName[VN_SIZE]; 596 593 lstrcpy(szParentClassName,buffer+i2); 597 594 i2+=lstrlen(buffer+i2)+1; 598 595 596 CClass *pClass = NULL; 599 597 if(szParentClassName[0]) 600 psi->pobj_ParentClass=pobj_DBClass->check(szParentClassName); 601 else psi->pobj_ParentClass=0; 598 pClass=pobj_DBClass->check(szParentClassName); 602 599 603 600 //ID 604 psi->id=*(long *)(buffer+i2);601 int id=*(long *)(buffer+i2); 605 602 i2+=sizeof(long); 606 603 607 604 //名前 608 psi->name=(char *)HeapAlloc(hHeap,0,lstrlen(buffer+i2)+1); 609 lstrcpy(psi->name,buffer+i2); 610 i2+=lstrlen(buffer+i2)+1; 611 612 psi->CompileAddress=*(long *)(buffer+i2); 613 i2+=sizeof(long); 614 psi->EndOpAddr=*(long *)(buffer+i2); 615 i2+=sizeof(long); 616 617 psi->bVirtual=*(long *)(buffer+i2); 618 i2+=sizeof(long); 619 620 psi->bCompile=1; 605 char *name = buffer+i2; 606 i2+=lstrlen(buffer+i2)+1; 607 608 // オブジェクトを生成 609 pUserProc = new UserProc( name, UserProc::Function, false, false, false ); 610 pUserProc->pNextData=0; 611 pUserProc->id=id; 612 pUserProc->SetParentClass( pClass ); 613 614 pUserProc->beginOpAddress=*(long *)(buffer+i2); 615 i2+=sizeof(long); 616 pUserProc->endOpAddress=*(long *)(buffer+i2); 617 i2+=sizeof(long); 618 619 pUserProc->CompleteCompile(); 621 620 622 621 //ローカル変数情報 623 psi->VarNum=*(long *)(buffer+i2); 624 i2+=sizeof(long); 625 psi->pVar=(VARIABLE *)HeapAlloc(hHeap,0,psi->VarNum*sizeof(VARIABLE)+1); 626 for(i4=0;i4<psi->VarNum;i4++){ 627 VARIABLE *pVar=&psi->pVar[i4]; 628 629 //ローカル変数名 630 lstrcpy(pVar->name,buffer+i2); 622 pUserProc->localVars.clear(); 623 int maxLocalVar=*(long *)(buffer+i2); 624 i2+=sizeof(long); 625 for(i3=0;i3<maxLocalVar;i3++){ 626 //変数名 627 char *name = buffer+i2; 631 628 i2+=lstrlen(buffer+i2)+1; 632 629 633 //型634 pVar->type=*(long *)(buffer+i2);635 i2+=sizeof(long); 636 637 //型の拡張情報638 GetLpIndex_DebugFile(buffer,&i2,pVar->type,&pVar->u.index); 639 640 //参照型パラメータかどうか 641 pVar->fRef=(long)buffer[i2++];642 643 //配列かどうか644 pVar->bArray=(long)buffer[i2++]; 645 if( pVar->bArray){646 for(i5=0;;i5++){647 //配列要素648 pVar->SubScripts[i5]=*(long *)(buffer+i2);630 int basicType = *(long *)(buffer+i2); 631 i2+=sizeof(long); 632 633 Type type( basicType ); 634 GetLpIndex_DebugFile(buffer,&i2,type); 635 636 bool isRef = (buffer[i2++]) ? true:false; 637 638 bool isArray = (buffer[i2++]) ? true:false; 639 640 Variable *pVar = new Variable( name, type, false, isRef ); 641 642 if(isArray){ 643 int SubScripts[MAX_ARRAYDIM]; 644 for(i4=0;;i4++){ 645 SubScripts[i4]=*(long *)(buffer+i2); 649 646 i2+=sizeof(long); 650 647 651 if( pVar->SubScripts[i5]==-1) break;648 if(SubScripts[i4]==-1) break; 652 649 } 650 651 pVar->SetArray( SubScripts ); 653 652 } 654 653 … … 661 660 i2+=sizeof(long); 662 661 663 //メモリ 上の位置662 //メモリ位置 664 663 pVar->offset=*(long *)(buffer+i2); 665 664 i2+=sizeof(long); 665 666 //変数を追加 667 pUserProc->localVars.push_back( pVar ); 666 668 } 667 669 668 670 669 671 ///////////////////////////////// 670 // 格納位置を計算してp siをセット672 // 格納位置を計算してpUserProcをセット 671 673 ///////////////////////////////// 672 674 673 i4=hash_default(p si->name);674 675 SubInfo*psi2;675 i4=hash_default(pUserProc->GetName().c_str()); 676 677 UserProc *psi2; 676 678 if(ppSubHash[i4]){ 677 679 psi2=ppSubHash[i4]; 678 680 while(1){ 679 681 if(psi2->pNextData==0){ 680 psi2->pNextData=p si;682 psi2->pNextData=pUserProc; 681 683 break; 682 684 } … … 685 687 } 686 688 else{ 687 ppSubHash[i4]=p si;689 ppSubHash[i4]=pUserProc; 688 690 } 689 691 } … … 723 725 724 726 //型 725 pobj_c->ppobj_Member[i4]->TypeInfo.type=*(long *)(buffer+i2);727 Type type( *(long *)(buffer+i2) ); 726 728 i2+=sizeof(long); 727 729 728 730 //型の拡張情報 729 GetLpIndex_DebugFile(buffer,&i2,pobj_c->ppobj_Member[i4]->TypeInfo.type,&pobj_c->ppobj_Member[i4]->TypeInfo.u.lpIndex); 731 GetLpIndex_DebugFile(buffer,&i2,type); 732 733 pobj_c->ppobj_Member[i4]->SetType( type.GetBasicType(), type.GetIndex() ); 730 734 731 735 pobj_c->ppobj_Member[i4]->dwAccess=*(long *)(buffer+i2); … … 757 761 if(pobj_temp_c==0) pobj_temp_c=pobj_c; 758 762 i5=hash_default(temp2); 759 p si=ppSubHash[i5];763 pUserProc=ppSubHash[i5]; 760 764 while(1){ 761 if( lstrcmp(psi->name,temp2)==0&&psi->pobj_ParentClass==pobj_temp_c) break;762 p si=psi->pNextData;763 } 764 method->p si=psi;765 if( pUserProc->GetName() == temp2 &&pUserProc->GetParentClassPtr()==pobj_temp_c) break; 766 pUserProc=pUserProc->pNextData; 767 } 768 method->pUserProc=pUserProc; 765 769 766 770 pobj_c->methods.push_back( method ); … … 781 785 782 786 //型 783 member->TypeInfo.type=*(long *)(buffer+i2);787 Type type( *(long *)(buffer+i2) ); 784 788 i2+=sizeof(long); 785 789 786 790 //型の拡張情報 787 GetLpIndex_DebugFile(buffer,&i2,member->TypeInfo.type,&member->TypeInfo.u.lpIndex); 791 GetLpIndex_DebugFile(buffer,&i2,type); 792 793 member->SetType( type.GetBasicType(), type.GetIndex() ); 788 794 789 795 member->dwAccess=*(long *)(buffer+i2); … … 800 806 801 807 802 extern SubInfo**ppSubHash;808 extern UserProc **ppSubHash; 803 809 ppSubHash=this->ppSubHash; 804 810 pSub_DebugSys_EndProc=GetSubHash("_DebugSys_EndProc"); … … 956 962 ppConstHash=this->ppConstHash; 957 963 958 //グローバル変数に関する情報959 extern VARIABLE *GlobalVar;960 extern int MaxGlobalVarNum;961 GlobalVar=this->GlobalVar;962 MaxGlobalVarNum=this->MaxGlobalVarNum;963 964 964 //グローバル実行領域のサイズ 965 965 extern int GlobalOpBufferSize; … … 969 969 extern char **ppMacroNames; 970 970 ppMacroNames=0; 971 extern SubInfo**ppSubHash;971 extern UserProc **ppSubHash; 972 972 extern int SubNum; 973 973 ppSubHash=this->ppSubHash; 974 974 SubNum=this->SubNum; 975 975 976 extern SubInfo*pSub_DebugSys_EndProc;976 extern UserProc *pSub_DebugSys_EndProc; 977 977 pSub_DebugSys_EndProc=this->pSub_DebugSys_EndProc; 978 978 … … 989 989 HeapDefaultFree(IncludeFileInfo.ppFileNames[i2]); 990 990 HeapDefaultFree(IncludeFileInfo.ppFileNames); 991 992 //グローバル変数に関する情報を解放993 HeapDefaultFree(GlobalVar);994 995 //ローカル変数に関する情報を解放996 SubInfo *psi;997 for(i2=0;i2<MAX_HASH;i2++){998 psi=ppSubHash[i2];999 while(psi){1000 if(psi->bCompile)1001 HeapDefaultFree(psi->pVar);1002 1003 psi=psi->pNextData;1004 }1005 }1006 991 1007 992 //クラスに関するメモリを解放
Note:
See TracChangeset
for help on using the changeset viewer.