Changeset 206 in dev for trunk/abdev/BasicCompiler64/MakePeHdr.cpp
- Timestamp:
- Jul 12, 2007, 2:58:26 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler64/MakePeHdr.cpp
r202 r206 1 #include "stdafx.h" 2 1 3 #include <jenga/include/common/Environment.h> 2 4 … … 4 6 5 7 #include <LexicalScopingImpl.h> 6 #include <Class Impl.h>8 #include <Class.h> 7 9 #include <Compiler.h> 8 10 11 #include <../Enum.h> 12 9 13 #include "../BasicCompiler_Common/common.h" 14 #include "../BasicCompiler_Common/DebugSection.h" 10 15 #include "Opcode.h" 11 16 … … 16 21 17 22 // グローバル関数、静的メソッド 18 UserProc23 const UserProc 19 24 *pSub_System_StartupProgram, 20 25 *pSub_DebugSys_StartProc, … … 36 41 37 42 // 動的メソッド 38 UserProc43 const UserProc 39 44 *pUserProc_System_CGarbageCollection_RegisterGlobalRoots; 40 45 … … 160 165 161 166 //クラス名を取得(詳細情報はGetAllClassInfoで取得) 162 // GetSubInfo関数の中で参照されるオブジェクト名を事前に取得する。167 // CollectUserProcs関数の中で参照されるオブジェクト名を事前に取得する。 163 168 // ※オブジェクトの内容までは取得しない 164 169 compiler.GetMeta().GetClasses().CollectClassesForNameOnly( Smoothie::Lexical::source ); … … 171 176 172 177 //サブルーチン(ユーザー定義、DLL関数)の識別子、アドレスを取得 173 Smoothie::Temp::pCompilingClass = NULL;174 GetSubInfo();175 176 // クラス情報を取得(※注 - GetSubInfoの後に呼び出す)178 compiler.pCompilingClass = NULL; 179 UserProcs::CollectUserProcs( Smoothie::Lexical::source, compiler.GetMeta().GetUserProcs() ); 180 181 // クラス情報を取得(※注 - CollectUserProcsの後に呼び出す) 177 182 compiler.GetMeta().GetClasses().GetAllClassInfo(); 178 183 179 compiler.GetMeta().AutoWrite( Jenga::Common::Environment::GetAppDir() + "\\meta_test.xml" ); 184 // サブルーチン(ユーザー定義、DLL関数)のイテレータの準備 185 compiler.GetMeta().GetUserProcs().Iterator_Init(); 186 187 /* 188 if( !compiler.GetMeta().Write( Jenga::Common::Environment::GetAppDir() + "\\meta_test.xml" ) ) 189 { 190 MessageBox(0,"XML書き込みに失敗","test",0); 191 } 192 MetaImpl *pTempMeta = new MetaImpl(); 193 if( !pTempMeta->Read( Jenga::Common::Environment::GetAppDir() + "\\meta_test.xml" ) ) 194 { 195 MessageBox(0,"XML読み込みに失敗","test",0); 196 } 197 compiler.GetMeta() = (*pTempMeta); 198 */ 180 199 181 200 //コードと行番号の関係 … … 347 366 extern CStackFrame *pobj_sf; 348 367 pobj_sf=new CStackFrame(); 368 369 trace_for_sourcecodestep( "★★★ グローバル領域のコンパイルを開始" ); 349 370 350 371 … … 399 420 400 421 //call _System_Call_Destructor_of_GlobalObject 401 extern UserProc *pSub_System_Call_Destructor_of_GlobalObject;422 extern const UserProc *pSub_System_Call_Destructor_of_GlobalObject; 402 423 op_call(pSub_System_Call_Destructor_of_GlobalObject); 403 424 … … 557 578 ExportNamesLength=lstrlen(lpExportNames)+1; 558 579 559 extern GlobalProc **ppSubHash; 560 GlobalProc *pUserProc,*psi2; 580 UserProc *pUserProc,*psi2; 561 581 while(1){ 562 582 //辞書順にサーチ 563 583 temporary[0]=0; 564 for(i=0,psi2=0;i<MAX_HASH;i++){ 565 pUserProc=ppSubHash[i]; 566 while(pUserProc){ 567 if(pUserProc->IsExport()){ 568 if(temporary[0]=='\0'){ 584 compiler.GetMeta().GetUserProcs().Iterator_Reset(); 585 while( compiler.GetMeta().GetUserProcs().Iterator_HasNext() ) 586 { 587 pUserProc = compiler.GetMeta().GetUserProcs().Iterator_GetNext(); 588 if(pUserProc->IsExport()){ 589 if(temporary[0]=='\0'){ 590 lstrcpy(temporary,pUserProc->GetName().c_str()); 591 psi2=pUserProc; 592 } 593 else{ 594 i3=lstrlen(temporary); 595 i4=(int)pUserProc->GetName().size(); 596 if(i3<i4) i3=i4; 597 if(memcmp(temporary,pUserProc->GetName().c_str(),i3)>0){ 569 598 lstrcpy(temporary,pUserProc->GetName().c_str()); 570 599 psi2=pUserProc; 571 600 } 572 else{573 i3=lstrlen(temporary);574 i4=(int)pUserProc->GetName().size();575 if(i3<i4) i3=i4;576 if(memcmp(temporary,pUserProc->GetName().c_str(),i3)>0){577 lstrcpy(temporary,pUserProc->GetName().c_str());578 psi2=pUserProc;579 }580 }581 601 } 582 pUserProc=pUserProc->pNextData;583 602 } 584 603 } … … 589 608 590 609 if( pUserProc->GetName() == "DllMain" ){ 591 DllMain_EntryPoint=pUserProc-> beginOpAddress;610 DllMain_EntryPoint=pUserProc->GetBeginOpAddress(); 592 611 } 593 612 594 613 lpdwExportAddressTable=(DWORD *)HeapReAlloc(hHeap,0,lpdwExportAddressTable,(ExportNum+1)*sizeof(DWORD)); 595 lpdwExportAddressTable[ExportNum]=pUserProc-> beginOpAddress;614 lpdwExportAddressTable[ExportNum]=pUserProc->GetBeginOpAddress(); 596 615 597 616 lpdwExportNamePointerTable=(DWORD *)HeapReAlloc(hHeap,0,lpdwExportNamePointerTable,(ExportNum+1)*sizeof(DWORD)); … … 800 819 //(デバッグ情報で利用される) 801 820 extern int AllInitGlobalVarSize; 802 BOOST_FOREACH( Variable *pVar, globalVars ){ 803 if(pVar->offset&0x80000000){ 804 pVar->offset=(pVar->offset&0x7FFFFFFF)+AllInitGlobalVarSize; 821 BOOST_FOREACH( Variable *pVar, compiler.GetMeta().GetGlobalVars() ){ 822 if(pVar->GetOffsetAddress()&0x80000000){ 823 pVar->SetOffsetAddress( 824 (pVar->GetOffsetAddress()&0x7FFFFFFF)+AllInitGlobalVarSize 825 ); 805 826 } 806 827 } … … 1088 1109 // ※x86はRVAからのオフセット。x64はRPI(実行中アドレス)からのオフセット 1089 1110 for(i=0;i<pobj_ImportAddrSchedule->num;i++){ 1090 DllProc *pDllProc; 1091 pDllProc=pobj_ImportAddrSchedule->ppdi[i]; 1111 const DllProc *pDllProc = pobj_ImportAddrSchedule->ppdi[i]; 1092 1112 *((long *)(OpBuffer+pobj_ImportAddrSchedule->pObpValues[i]))= 1093 1113 MemPos_ImportSection+ … … 1101 1121 // プロシージャポインタスケジュール 1102 1122 for(i=0;i<pobj_SubAddrSchedule->num;i++){ 1103 if(pobj_SubAddrSchedule->ppsi[i]-> beginOpAddress==01104 &&pobj_SubAddrSchedule->ppsi[i]-> endOpAddress==0){1123 if(pobj_SubAddrSchedule->ppsi[i]->GetBeginOpAddress()==0 1124 &&pobj_SubAddrSchedule->ppsi[i]->GetEndOpAddress()==0){ 1105 1125 SetError(300,NULL,-1); 1106 1126 } … … 1108 1128 if(pobj_SubAddrSchedule->pbCall[i]){ 1109 1129 *((long *)(OpBuffer+pobj_SubAddrSchedule->pObpValues[i]))= 1110 pobj_SubAddrSchedule->ppsi[i]-> beginOpAddress-(pobj_SubAddrSchedule->pObpValues[i]+sizeof(long));1130 pobj_SubAddrSchedule->ppsi[i]->GetBeginOpAddress()-(pobj_SubAddrSchedule->pObpValues[i]+sizeof(long)); 1111 1131 } 1112 1132 else{ 1113 1133 *((long *)(OpBuffer+pobj_SubAddrSchedule->pObpValues[i]))= 1114 pobj_SubAddrSchedule->ppsi[i]-> beginOpAddress+ImageBase+MemPos_CodeSection;1134 pobj_SubAddrSchedule->ppsi[i]->GetBeginOpAddress()+ImageBase+MemPos_CodeSection; 1115 1135 } 1116 1136 }
Note:
See TracChangeset
for help on using the changeset viewer.