- Timestamp:
- Aug 5, 2007, 3:47:49 AM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/Compile_Object.cpp
r259 r263 61 61 if( subs.size() == 1 ){ 62 62 char temporary[VN_SIZE]; 63 sprintf( temporary, " ActiveBasic.Core._System_TypeBase.Search(\"\",\"%s\"))", pobj_c->GetName().c_str() );63 sprintf( temporary, "_System_TypeBase_Search(\"\",\"%s\"))", pobj_c->GetName().c_str() ); 64 64 65 65 Opcode_CallProc(temporary, -
trunk/abdev/BasicCompiler32/Compile_ProcOp.cpp
r261 r263 121 121 }; 122 122 123 compiler.codeGenerator.PutOld( NativeCode( (const char *)Buffer_allrem, 178 ) );123 compiler.codeGenerator.PutOld( NativeCode( (const char *)Buffer_allrem, 178, false ) ); 124 124 } 125 125 else if( userProc.GetName() == "_aullrem" ){ … … 137 137 }; 138 138 139 compiler.codeGenerator.PutOld( NativeCode( (const char *)Buffer_aullrem, 117 ) );139 compiler.codeGenerator.PutOld( NativeCode( (const char *)Buffer_aullrem, 117, false ) ); 140 140 } 141 141 else if( userProc.GetName() == "_allmul" ){ … … 145 145 }; 146 146 147 compiler.codeGenerator.PutOld( NativeCode( (const char *)Buffer_allmul, 52 ) );147 compiler.codeGenerator.PutOld( NativeCode( (const char *)Buffer_allmul, 52, false ) ); 148 148 } 149 149 else if( userProc.GetName() == "_alldiv" ){ … … 153 153 }; 154 154 155 compiler.codeGenerator.PutOld( NativeCode( (const char *)Buffer_alldiv, 170 ) );155 compiler.codeGenerator.PutOld( NativeCode( (const char *)Buffer_alldiv, 170, false ) ); 156 156 } 157 157 else if( userProc.GetName() == "_aulldiv" ){ … … 168 168 }; 169 169 170 compiler.codeGenerator.PutOld( NativeCode( (const char *)Buffer_aulldiv, 104 ) );170 compiler.codeGenerator.PutOld( NativeCode( (const char *)Buffer_aulldiv, 104, false ) ); 171 171 } 172 172 else if( userProc.GetName() == "_allshl" ){ … … 176 176 }; 177 177 178 compiler.codeGenerator.PutOld( NativeCode( (const char *)Buffer_allshl, 31 ) );178 compiler.codeGenerator.PutOld( NativeCode( (const char *)Buffer_allshl, 31, false ) ); 179 179 } 180 180 else if( userProc.GetName() == "_allshr" ){ … … 184 184 }; 185 185 186 compiler.codeGenerator.PutOld( NativeCode( (const char *)Buffer_allshr, 33 ) );186 compiler.codeGenerator.PutOld( NativeCode( (const char *)Buffer_allshr, 33, false ) ); 187 187 } 188 188 else if( userProc.GetName() == "_aullshr" ){ … … 208 208 }; 209 209 210 compiler.codeGenerator.PutOld( NativeCode( (const char *)Buffer_aullshr, 31 ) );210 compiler.codeGenerator.PutOld( NativeCode( (const char *)Buffer_aullshr, 31, false ) ); 211 211 } 212 212 else{ … … 744 744 745 745 _compile_proc( &userProc ); 746 746 747 /* 747 748 // ログを履く -
trunk/abdev/BasicCompiler32/MakePeHdr.cpp
r261 r263 239 239 240 240 //コードと行番号の関係 241 extern LINEINFO *pLineInfo; 242 extern int MaxLineInfoNum; 243 pLineInfo=(LINEINFO *)HeapAlloc(hHeap,0,1); 244 MaxLineInfoNum=0; 241 extern SourceLines oldSourceLines; 242 oldSourceLines.clear(); 245 243 246 244 … … 887 885 888 886 //機械語コードとBasicコードの関係を整理 889 extern LINEINFO *pLineInfo; 890 extern int MaxLineInfoNum; 887 extern SourceLines oldSourceLines; 891 888 int MinObp,MaxObp; 892 LINEINFO *pTempLineInfo; 893 pTempLineInfo=(LINEINFO *)HeapAlloc(hHeap,0,MaxLineInfoNum*sizeof(LINEINFO)); 894 i2=0; 889 SourceLines tempSourceLines; 895 890 MaxObp=0; 896 891 while(1){ 897 for(i3=0,MinObp=0x0FFFFFFF;i3< MaxLineInfoNum;i3++){898 if( pLineInfo[i3].TopObp<MinObp&&MaxObp<pLineInfo[i3].TopObp){899 MinObp= pLineInfo[i3].TopObp;892 for(i3=0,MinObp=0x0FFFFFFF;i3<(int)oldSourceLines.size();i3++){ 893 if(oldSourceLines[i3].GetNativeCodePos()<MinObp&&MaxObp<oldSourceLines[i3].GetNativeCodePos()){ 894 MinObp=oldSourceLines[i3].GetNativeCodePos(); 900 895 i4=i3; 901 896 } 902 897 } 903 898 if(MinObp==0x0FFFFFFF) break; 904 pTempLineInfo[i2]=pLineInfo[i4]; 905 MaxObp=pTempLineInfo[i2].TopObp; 906 i2++; 907 } 908 HeapDefaultFree(pLineInfo); 909 pLineInfo=(LINEINFO *)HeapAlloc(hHeap,0,i2*sizeof(LINEINFO)); 910 memcpy(pLineInfo,pTempLineInfo,i2*sizeof(LINEINFO)); 911 MaxLineInfoNum=i2; 912 HeapDefaultFree(pTempLineInfo); 899 tempSourceLines.push_back( oldSourceLines[i4] ); 900 MaxObp=tempSourceLines.back().GetNativeCodePos(); 901 } 902 oldSourceLines = tempSourceLines; 913 903 914 904 //デバッグセクションを生成 … … 1216 1206 delete pobj_GlobalVarSchedule; 1217 1207 1218 /* 1208 1219 1209 compiler.linker.SetImageBase( ImageBase ); 1220 1210 compiler.linker.ResolveDataTableSchedules( MemPos_DataSection ); 1221 1211 compiler.linker.ResolveDllProcSchedules( MemPos_CodeSection, MemPos_ImportSection, LookupSize, HintSize ); 1222 1212 compiler.linker.ResolveUserProcSchedules( MemPos_CodeSection ); 1223 compiler.linker.ResolveDataTableSchedules( MemPos_RWSection ); 1224 */ 1213 compiler.linker.ResolveGlobalVarSchedules( MemPos_RWSection ); 1214 1215 if( obp == compiler.linker.GetNativeCode().GetSize() ) 1216 { 1217 //memcpy( OpBuffer, compiler.linker.GetNativeCode().GetCodeBuffer(), compiler.linker.GetNativeCode().GetSize() ); 1218 } 1219 else 1220 { 1221 SetError(); 1222 } 1223 1225 1224 1226 1225 -
trunk/abdev/BasicCompiler64/Compile_Object.cpp
r262 r263 60 60 if( subs.size() == 1 ){ 61 61 char temporary[VN_SIZE]; 62 sprintf( temporary, " ActiveBasic.Core._System_TypeBase.Search(\"\",\"%s\"))", pobj_c->GetName().c_str() );62 sprintf( temporary, "_System_TypeBase_Search(\"\",\"%s\"))", pobj_c->GetName().c_str() ); 63 63 64 64 Opcode_CallProc(temporary, … … 258 258 259 259 //jnzの番地 260 int jnz_back; 261 jnz_back=obp; 260 //int jnz_back=obp; 262 261 263 262 //mov qword ptr[rsp+offset],rcx ※スタックフレームを利用 … … 280 279 281 280 //jnz ↑ 282 compiler.codeGenerator.op_jne( jnz_back-obp, sizeof(long), false, true );281 //compiler.codeGenerator.op_jne( jnz_back-obp, sizeof(long), false, true ); 283 282 284 283 -
trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp
r262 r263 140 140 && userProc.HasParentClass() 141 141 && userProc.GetParentClass().GetName() == "_System_TypeBase" ){ 142 143 142 compiler.objectModule.meta.GetClasses().Compile_System_InitializeUserTypes(); 144 143 } … … 670 669 671 670 672 pUserProc-> SetEndOpAddress( obp );671 pUserProc->_endOpAddressOld = obp; 673 672 674 673 -
trunk/abdev/BasicCompiler64/Compile_Statement.cpp
r262 r263 272 272 { 273 273 //jmp ...(schedule) 274 extern int obp;275 274 compiler.codeGenerator.op_jmp_goto_schedule( (const std::string)(Parameter + 1), 0, cp ); 276 275 } … … 289 288 { 290 289 //jmp ...(schedule) 291 extern int obp;292 290 compiler.codeGenerator.op_jmp_goto_schedule( "", LineNum, cp ); 293 291 } -
trunk/abdev/BasicCompiler64/MakePeHdr.cpp
r262 r263 222 222 223 223 //コードと行番号の関係 224 extern LINEINFO *pLineInfo; 225 extern int MaxLineInfoNum; 226 pLineInfo=(LINEINFO *)HeapAlloc(hHeap,0,1); 227 MaxLineInfoNum=0; 224 extern SourceLines oldSourceLines; 225 oldSourceLines.clear(); 228 226 229 227 … … 387 385 388 386 //未完成 389 // OpBuffer[obp++]=(char)0xCC;387 //breakpoint; 390 388 391 389 //sub rsp,スタックフレームサイズ … … 503 501 ////////////////////////////////////////////////////////// 504 502 503 504 505 trace( "コード生成が終了しました。" ); 506 507 vector<ObjectModule *> masterObjectModules; 508 masterObjectModules.push_back( &compiler.objectModule ); 509 compiler.linker.Link( masterObjectModules ); 505 510 506 511 … … 836 841 837 842 //機械語コードとBasicコードの関係を整理 838 extern LINEINFO *pLineInfo; 839 extern int MaxLineInfoNum; 843 extern SourceLines oldSourceLines; 840 844 int MinObp,MaxObp; 841 LINEINFO *pTempLineInfo; 842 pTempLineInfo=(LINEINFO *)HeapAlloc(hHeap,0,MaxLineInfoNum*sizeof(LINEINFO)); 843 i2=0; 845 SourceLines tempSourceLines; 844 846 MaxObp=0; 845 847 while(1){ 846 for(i3=0,MinObp=0x0FFFFFFF;i3< MaxLineInfoNum;i3++){847 if( pLineInfo[i3].TopObp<MinObp&&MaxObp<pLineInfo[i3].TopObp){848 MinObp= pLineInfo[i3].TopObp;848 for(i3=0,MinObp=0x0FFFFFFF;i3<oldSourceLines.size();i3++){ 849 if(oldSourceLines[i3].GetNativeCodePos()<MinObp&&MaxObp<oldSourceLines[i3].GetNativeCodePos()){ 850 MinObp=oldSourceLines[i3].GetNativeCodePos(); 849 851 i4=i3; 850 852 } 851 853 } 852 854 if(MinObp==0x0FFFFFFF) break; 853 pTempLineInfo[i2]=pLineInfo[i4]; 854 MaxObp=pTempLineInfo[i2].TopObp; 855 i2++; 856 } 857 HeapDefaultFree(pLineInfo); 858 pLineInfo=(LINEINFO *)HeapAlloc(hHeap,0,i2*sizeof(LINEINFO)); 859 memcpy(pLineInfo,pTempLineInfo,i2*sizeof(LINEINFO)); 860 MaxLineInfoNum=i2; 861 HeapDefaultFree(pTempLineInfo); 855 tempSourceLines.push_back( oldSourceLines[i4] ); 856 MaxObp=tempSourceLines.back().GetNativeCodePos(); 857 } 858 oldSourceLines = tempSourceLines; 862 859 863 860 //デバッグセクションを生成 … … 1165 1162 1166 1163 1164 1165 compiler.linker.SetImageBase( ImageBase ); 1166 compiler.linker.ResolveDataTableSchedules( MemPos_DataSection ); 1167 compiler.linker.ResolveDllProcSchedules( MemPos_CodeSection, MemPos_ImportSection, LookupSize, HintSize ); 1168 compiler.linker.ResolveUserProcSchedules( MemPos_CodeSection ); 1169 compiler.linker.ResolveGlobalVarSchedules( MemPos_RWSection ); 1170 1171 if( obp == compiler.linker.GetNativeCode().GetSize() ) 1172 { 1173 memcpy( OpBuffer, compiler.linker.GetNativeCode().GetCodeBuffer(), compiler.linker.GetNativeCode().GetSize() ); 1174 } 1175 else 1176 { 1177 SetError(); 1178 } 1179 1180 1167 1181 //////////////////////////////// 1168 1182 // リソースアドレススケジュール -
trunk/abdev/BasicCompiler64/Opcode.h
r262 r263 45 45 46 46 47 class CStackFrame:public CSchedule{ 47 class CStackFrame 48 { 48 49 /////////////////////////// 49 50 // スタックフレーム管理 50 51 /////////////////////////// 52 53 PertialSchedules pertialSchedules; 51 54 52 55 int lowest_sp; //スタックポインタの最下位位置 -
trunk/abdev/BasicCompiler64/stack_frame.cpp
r232 r263 39 39 40 40 //add reg,now_sp 41 compiler.codeGenerator.op_add_RV( reg, now_sp ); 42 43 //スケジュールをセット 44 obp-=sizeof(long); 45 add(); 46 obp+=sizeof(long); 41 pertialSchedules.push_back( 42 compiler.codeGenerator.op_add_RV( reg, now_sp, Schedule::None, true ) 43 ); 47 44 } 48 45 int CStackFrame::push(int reg){ … … 53 50 54 51 //mov qword ptr[rsp+offset],reg 55 compiler.codeGenerator.op_mov_MR(sizeof(_int64),reg,REG_RSP,now_sp,MOD_BASE_DISP32); 56 57 //スケジュールをセット 58 obp-=sizeof(long); 59 add(); 60 obp+=sizeof(long); 52 pertialSchedules.push_back( 53 compiler.codeGenerator.op_mov_MR(sizeof(_int64),reg,REG_RSP,now_sp,MOD_BASE_DISP32, Schedule::None, true) 54 ); 61 55 62 56 return now_sp; … … 68 62 if(varSize==sizeof(double)){ 69 63 //movlpd qword ptr[rsp+offset],xmm_reg 70 compiler.codeGenerator.op_movlpd_MR(xmm_reg,REG_RSP,now_sp,MOD_BASE_DISP32); 64 pertialSchedules.push_back( 65 compiler.codeGenerator.op_movlpd_MR(xmm_reg,REG_RSP,now_sp,MOD_BASE_DISP32, Schedule::None, true ) 66 ); 71 67 } 72 68 if(varSize==sizeof(float)){ 73 69 //movss dword ptr[rsp+offset],xmm_reg 74 compiler.codeGenerator.op_movss_MR( xmm_reg, REG_RSP, now_sp, MOD_BASE_DISP32 ); 70 pertialSchedules.push_back( 71 compiler.codeGenerator.op_movss_MR( xmm_reg, REG_RSP, now_sp, MOD_BASE_DISP32, Schedule::None, true ) 72 ); 75 73 } 76 77 //スケジュールをセット78 obp-=sizeof(long);79 add();80 obp+=sizeof(long);81 74 } 82 75 void CStackFrame::ref_offset_data( int reg, int sp_offset ){ 83 76 //mov reg,qword ptr[rsp+offset] ※スタックフレームを利用 84 compiler.codeGenerator.op_mov_RM(sizeof(_int64),reg,REG_RSP,sp_offset,MOD_BASE_DISP32); 85 86 //スケジュールをセット 87 obp-=sizeof(long); 88 add(); 89 obp+=sizeof(long); 77 pertialSchedules.push_back( 78 compiler.codeGenerator.op_mov_RM(sizeof(_int64),reg,REG_RSP,sp_offset,MOD_BASE_DISP32, Schedule::None, true ) 79 ); 90 80 } 91 81 void CStackFrame::ref(int reg){ … … 95 85 if(varSize==sizeof(double)){ 96 86 //movlpd xmm_reg,qword ptr[rsp+offset] 97 compiler.codeGenerator.op_movlpd_RM(xmm_reg,REG_RSP,now_sp,MOD_BASE_DISP32); 87 pertialSchedules.push_back( 88 compiler.codeGenerator.op_movlpd_RM(xmm_reg,REG_RSP,now_sp,MOD_BASE_DISP32, Schedule::None, true ) 89 ); 98 90 } 99 91 if(varSize==sizeof(float)){ 100 92 //movss xmm_reg,dword ptr[rsp+offset] 101 compiler.codeGenerator.op_movss_MR( xmm_reg, REG_RSP, now_sp, MOD_BASE_DISP32 ); 93 pertialSchedules.push_back( 94 compiler.codeGenerator.op_movss_MR( xmm_reg, REG_RSP, now_sp, MOD_BASE_DISP32, Schedule::None, true ) 95 ); 102 96 } 103 104 //スケジュールをセット105 obp-=sizeof(long);106 add();107 obp+=sizeof(long);108 97 } 109 98 void CStackFrame::pop(int reg){ … … 121 110 } 122 111 void CStackFrame::RunningSchedule( int stackFrameSize ){ 123 for(int i=0;i<num;i++){ 124 *((long *)(OpBuffer+pObpValues[i])) += stackFrameSize; 112 BOOST_FOREACH( const PertialSchedule *pPertialSchedule, pertialSchedules ) 113 { 114 compiler.codeGenerator.opfix_offset( pPertialSchedule, stackFrameSize ); 125 115 } 126 116 } -
trunk/abdev/BasicCompiler_Common/BasicCompiler.h
r209 r263 57 57 char szDebugExeForDll[1024]; 58 58 59 //デバッグ用行番号情報60 LINEINFO *pLineInfo;61 int MaxLineInfoNum;62 63 59 //ウォッチリスト 64 60 int width_WatchColumn_Expression=200; -
trunk/abdev/BasicCompiler_Common/BreakPoint.cpp
r256 r263 3 3 #include <jenga/include/common/Environment.h> 4 4 #include <jenga/include/smoothie/Source.h> 5 6 #include <Compiler.h> 5 7 6 8 #include "common.h" … … 69 71 70 72 if(i2==piLine[nCount]){ 71 extern int MaxLineInfoNum; 72 extern LINEINFO *pLineInfo; 73 extern SourceLines oldSourceLines; 73 74 74 75 loop: … … 77 78 78 79 int i3; 79 for(i3=0;i3< MaxLineInfoNum-1;i3++){80 if( pLineInfo[i3].TopCp==tempCp) break;80 for(i3=0;i3<(int)oldSourceLines.size()-1;i3++){ 81 if(oldSourceLines[i3].GetSourceCodePos()==tempCp) break; 81 82 } 82 if(i3== MaxLineInfoNum-1){83 if(i3==oldSourceLines.size()-1){ 83 84 i2--; 84 85 goto loop; 85 86 } 86 87 87 nativeCodeBuffer[ pLineInfo[i3].TopObp]=(char)0xCC;88 nativeCodeBuffer[oldSourceLines[i3].GetNativeCodePos()]=(char)0xCC; 88 89 89 90 nCount++; -
trunk/abdev/BasicCompiler_Common/Compile.cpp
r261 r263 25 25 //With情報 26 26 WITHINFO WithInfo; 27 28 //デバッグ用行番号情報 29 SourceLines oldSourceLines; 27 30 28 31 … … 80 83 81 84 void NextLine(void){ 82 extern HANDLE hHeap; 83 extern int MaxLineInfoNum; 84 extern LINEINFO *pLineInfo; 85 if(MaxLineInfoNum){ 86 extern int obp; 87 if(pLineInfo[MaxLineInfoNum-1].TopObp==obp){ 88 pLineInfo[MaxLineInfoNum-1].TopCp=cp; 85 extern int obp; 86 87 extern SourceLines oldSourceLines; 88 if( oldSourceLines.size() ) 89 { 90 if( oldSourceLines.back().GetNativeCodePos() == obp ) 91 { 92 oldSourceLines.back().SetSourceCodePos( cp ); 89 93 return; 90 94 } 91 95 } 92 pLineInfo=(LINEINFO *)HeapReAlloc(hHeap,0,pLineInfo,(MaxLineInfoNum+1)*sizeof(LINEINFO));93 pLineInfo[MaxLineInfoNum].TopCp=cp;94 extern int obp;95 pLineInfo[MaxLineInfoNum].TopObp=obp;96 96 97 97 extern BOOL bDebugSupportProc; 98 98 extern BOOL bSystemProc; 99 pLineInfo[MaxLineInfoNum].dwCodeType=0; 100 if(bDebugSupportProc) 101 pLineInfo[MaxLineInfoNum].dwCodeType|=CODETYPE_DEBUGPROC; 102 if(bSystemProc) 103 pLineInfo[MaxLineInfoNum].dwCodeType|=CODETYPE_SYSTEMPROC; 104 105 MaxLineInfoNum++; 99 DWORD sourceLineType = 0; 100 if( bDebugSupportProc ) 101 { 102 sourceLineType |= CODETYPE_DEBUGPROC; 103 } 104 if( bSystemProc ) 105 { 106 sourceLineType |= CODETYPE_SYSTEMPROC; 107 } 108 oldSourceLines.push_back( SourceLine( (long)oldSourceLines.size(), obp, cp, sourceLineType ) ); 106 109 } 107 110 … … 334 337 breakpoint; 335 338 } 336 #if defined(_DEBUG)337 339 else 338 340 { 341 //#if defined(_DEBUG) 339 342 breakpoint; 340 } 341 #endif 343 //#endif 344 } 342 345 break; 343 346 … … 637 640 638 641 NextLine(); 642 compiler.codeGenerator.NextSourceLine(); 639 643 640 644 if(Command[0]==1){ -
trunk/abdev/BasicCompiler_Common/Debug.cpp
r259 r263 79 79 80 80 if(i2==iLineNum){ 81 extern int MaxLineInfoNum; 82 extern LINEINFO *pLineInfo; 81 extern SourceLines oldSourceLines; 83 82 84 83 loop: … … 87 86 88 87 int i3; 89 for(i3=0;i3< MaxLineInfoNum-1;i3++){90 if( pLineInfo[i3].TopCp==tempCp) break;91 } 92 if(i3== MaxLineInfoNum-1){88 for(i3=0;i3<(int)oldSourceLines.size()-1;i3++){ 89 if(oldSourceLines[i3].GetSourceCodePos()==tempCp) break; 90 } 91 if(i3==oldSourceLines.size()-1){ 93 92 i2--; 94 93 goto loop; 95 94 } 96 95 97 StepCursorObpSchedule= pLineInfo[i3].TopObp;96 StepCursorObpSchedule=oldSourceLines[i3].GetNativeCodePos(); 98 97 StepCursor_BackupChar=pobj_DBDebugSection->pobj_now->BreakStepCodeBuffer[StepCursorObpSchedule]; 99 98 -
trunk/abdev/BasicCompiler_Common/DebugMiddleFile.cpp
r259 r263 98 98 // コードと行番号の関係 99 99 //////////////////////// 100 extern int MaxLineInfoNum; 101 extern LINEINFO *pLineInfo; 102 103 //バッファが足りない場合は再確保 104 if(MaxLineInfoNum*sizeof(LINEINFO)<32768) i3=32768; 105 else i3=MaxLineInfoNum*sizeof(LINEINFO)+32768; 106 if(BufferSize<i2+i3){ 107 BufferSize+=i3; 108 buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize); 109 } 110 111 *(long *)(buffer+i2)=MaxLineInfoNum; 112 i2+=sizeof(long); 113 memcpy(buffer+i2,pLineInfo,MaxLineInfoNum*sizeof(LINEINFO)); 114 i2+=MaxLineInfoNum*sizeof(LINEINFO); 100 extern SourceLines oldSourceLines; 101 102 *(long *)(buffer+i2)=(long)oldSourceLines.size(); 103 i2+=sizeof(long); 104 BOOST_FOREACH( const SourceLine &sourceLine, oldSourceLines ) 105 { 106 *(long *)(buffer+i2) = sourceLine.GetLineNum(); 107 i2+=sizeof(long); 108 109 *(long *)(buffer+i2) = sourceLine.GetNativeCodePos(); 110 i2+=sizeof(long); 111 112 *(long *)(buffer+i2) = sourceLine.GetSourceCodePos(); 113 i2+=sizeof(long); 114 115 *(long *)(buffer+i2) = sourceLine.GetCodeType(); 116 i2+=sizeof(long); 117 118 //バッファが足りない場合は再確保 119 if(BufferSize<i2+32768){ 120 BufferSize+=32768; 121 buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufferSize); 122 } 123 } 115 124 116 125 … … 431 440 memcpy(buffer,OpBuffer,SizeOf_CodeSection); 432 441 433 int i2;434 for(i2=0;i2<MaxLineInfoNum;i2++){442 BOOST_FOREACH( const SourceLine &sourceLine, oldSourceLines ) 443 { 435 444 if(!( 436 pLineInfo[i2].dwCodeType&CODETYPE_SYSTEMPROC||437 pLineInfo[i2].dwCodeType&CODETYPE_DEBUGPROC438 )){445 sourceLine.IsInSystemProc() 446 || sourceLine.IsInDebugProc() ) ) 447 { 439 448 //int 3 440 buffer[ pLineInfo[i2].TopObp]=(char)0xCC;449 buffer[sourceLine.GetNativeCodePos()]=(char)0xCC; 441 450 } 442 451 } … … 487 496 488 497 //コードと行番号の関係 489 MaxLineInfoNum=*(long *)(buffer+i2); 490 i2+=sizeof(long); 491 pLineInfo=(LINEINFO *)HeapAlloc(hHeap,0,MaxLineInfoNum*sizeof(LINEINFO)+1); 492 memcpy(pLineInfo,buffer+i2,MaxLineInfoNum*sizeof(LINEINFO)); 493 i2+=MaxLineInfoNum*sizeof(LINEINFO); 498 int maxLineInfoNum; 499 maxLineInfoNum=*(long *)(buffer+i2); 500 i2+=sizeof(long); 501 for(i3=0;i3<maxLineInfoNum;i3++){ 502 int lineNum = *(long *)(buffer+i2); 503 i2+=sizeof(long); 504 505 int nativeCodePos = *(long *)(buffer+i2); 506 i2+=sizeof(long); 507 508 int sourceCodePos = *(long *)(buffer+i2); 509 i2+=sizeof(long); 510 511 DWORD sourceLineType = *(DWORD *)(buffer+i2); 512 i2+=sizeof(long); 513 514 oldSourceLines.push_back( SourceLine( lineNum, nativeCodePos, sourceCodePos, sourceLineType ) ); 515 } 494 516 495 517 … … 837 859 838 860 //コードと行番号の関係 839 extern int MaxLineInfoNum; 840 extern LINEINFO *pLineInfo; 841 MaxLineInfoNum=this->MaxLineInfoNum; 842 pLineInfo=this->pLineInfo; 861 extern SourceLines oldSourceLines; 862 oldSourceLines = this->oldSourceLines; 843 863 844 864 BreakStepCodeBuffer=pobj_DBBreakPoint->update(OpBuffer,SizeOf_CodeSection); … … 956 976 957 977 //コードと行番号の関係 958 extern int MaxLineInfoNum; 959 extern LINEINFO *pLineInfo; 960 MaxLineInfoNum=this->MaxLineInfoNum; 961 pLineInfo=this->pLineInfo; 978 extern SourceLines oldSourceLines; 979 oldSourceLines = this->oldSourceLines; 962 980 963 981 // クラス情報 … … 996 1014 delete this->pobj_DBClass; 997 1015 this->pobj_DBClass=0; 998 999 //コードと行番号の関係を解放1000 HeapDefaultFree(pLineInfo);1001 1016 1002 1017 //コードバッファを解放 -
trunk/abdev/BasicCompiler_Common/DebugSection.h
r206 r263 3 3 #include <jenga/include/smoothie/Source.h> 4 4 5 #include <Class.h> 6 #include <Procedure.h> 7 #include <Const.h> 8 5 #include <Compiler.h> 9 6 10 7 class CDebugSection{ … … 29 26 int SizeOf_CodeSection; 30 27 28 // オブジェクトモジュール 29 ObjectModule objectModule; 30 31 31 //インクルード情報 32 32 INCLUDEFILEINFO IncludeFileInfo; … … 36 36 37 37 //コードと行番号の関係 38 int MaxLineInfoNum; 39 LINEINFO *pLineInfo; 38 SourceLines oldSourceLines; 40 39 41 40 // クラス情報 -
trunk/abdev/BasicCompiler_Common/MakeExe.cpp
r256 r263 160 160 HeapDefaultFree(pBitmapResourceInfo); 161 161 HeapDefaultFree(pIconResourceInfo); 162 163 //コードと行番号の関係情報を解放164 extern LINEINFO *pLineInfo;165 HeapDefaultFree(pLineInfo);166 162 167 163 //コンパイルダイアログのプログレスバーを上げる -
trunk/abdev/BasicCompiler_Common/VarList.cpp
r259 r263 569 569 570 570 //行番号情報 571 extern int MaxLineInfoNum; 572 extern LINEINFO *pLineInfo; 571 extern SourceLines oldSourceLines; 573 572 for(i3=0;i3<(int)pobj_dti->iProcLevel+1;i3++){ 574 for(i2=0;i2< MaxLineInfoNum-1;i2++){575 if((ULONG_PTR)( pLineInfo[i2].TopObp+ImageBase+MemPos_CodeSection)<=pobj_dti->lplpObp[i3]&&576 pobj_dti->lplpObp[i3]<=(ULONG_PTR)( pLineInfo[i2+1].TopObp+ImageBase+MemPos_CodeSection)) break;577 } 578 if(i2== MaxLineInfoNum) pobj_dti->lpdwCp[i3]=-1;579 else pobj_dti->lpdwCp[i3]= pLineInfo[i2].TopCp;573 for(i2=0;i2<(int)oldSourceLines.size()-2;i2++){ 574 if((ULONG_PTR)(oldSourceLines[i2].GetNativeCodePos()+ImageBase+MemPos_CodeSection)<=pobj_dti->lplpObp[i3]&& 575 pobj_dti->lplpObp[i3]<=(ULONG_PTR)(oldSourceLines[i2+1].GetNativeCodePos()+ImageBase+MemPos_CodeSection)) break; 576 } 577 if(i2==oldSourceLines.size()-1) pobj_dti->lpdwCp[i3]=-1; 578 else pobj_dti->lpdwCp[i3]=oldSourceLines[i2].GetSourceCodePos(); 580 579 } 581 580 for(i3=0;i3<(int)pobj_dti->iProcLevel+1;i3++){ -
trunk/abdev/BasicCompiler_Common/common.h
r254 r263 140 140 141 141 142 #define CODETYPE_SYSTEMPROC 0x0001143 #define CODETYPE_DEBUGPROC 0x0002144 struct LINEINFO{145 int TopCp;146 int TopObp;147 DWORD dwCodeType;148 };149 142 struct RESOURCEDATAINFO{ 150 143 DWORD dwId; -
trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
r262 r263 238 238 } 239 239 pNativeCode = &nativeCode; 240 } 241 242 void NextSourceLine() 243 { 244 pNativeCode->NextSourceLine(); 240 245 } 241 246 -
trunk/abdev/BasicCompiler_Common/include/Linker.h
r258 r263 41 41 } 42 42 43 const NativeCode &GetNativeCode() const 44 { 45 return nativeCode; 46 } 47 43 48 void SetImageBase( DWORD imageBase ) 44 49 { -
trunk/abdev/BasicCompiler_Common/include/NativeCode.h
r258 r263 112 112 typedef std::vector<Schedule> Schedules; 113 113 114 #define CODETYPE_SYSTEMPROC 0x0001 115 #define CODETYPE_DEBUGPROC 0x0002 116 class SourceLine 117 { 118 int lineNum; 119 long nativeCodePos; 120 long sourceCodePos; 121 DWORD codeType; 122 123 // XMLシリアライズ用 124 private: 125 friend class boost::serialization::access; 126 template<class Archive> void serialize(Archive& ar, const unsigned int version) 127 { 128 trace_for_serialize( "serializing - SourceLine" ); 129 130 ar & BOOST_SERIALIZATION_NVP( lineNum ); 131 ar & BOOST_SERIALIZATION_NVP( nativeCodePos ); 132 ar & BOOST_SERIALIZATION_NVP( sourceCodePos ); 133 ar & BOOST_SERIALIZATION_NVP( codeType ); 134 } 135 136 public: 137 SourceLine( int lineNum, int nativeCodePos, int sourceCodePos, DWORD codeType ) 138 : lineNum( lineNum ) 139 , nativeCodePos( nativeCodePos ) 140 , sourceCodePos( sourceCodePos ) 141 , codeType( codeType ) 142 { 143 } 144 SourceLine() 145 { 146 } 147 148 int GetLineNum() const 149 { 150 return lineNum; 151 } 152 long GetNativeCodePos() const 153 { 154 return nativeCodePos; 155 } 156 long GetSourceCodePos() const 157 { 158 return sourceCodePos; 159 } 160 void SetSourceCodePos( int sourceCodePos ) 161 { 162 this->sourceCodePos = sourceCodePos; 163 } 164 DWORD GetCodeType() const 165 { 166 return codeType; 167 } 168 bool IsInSystemProc() const 169 { 170 return ( (codeType&CODETYPE_SYSTEMPROC) != 0 ); 171 } 172 bool IsInDebugProc() const 173 { 174 return ( (codeType&CODETYPE_DEBUGPROC) != 0 ); 175 } 176 }; 177 typedef std::vector<SourceLine> SourceLines; 178 114 179 class NativeCode 115 180 { … … 118 183 int size; 119 184 185 // リンカで解決しなければならないスケジュール 120 186 Schedules schedules; 187 188 // ソースコード行番号とネイティブコード位置の対応情報 189 SourceLines sourceLines; 121 190 122 191 // XMLシリアライズ用 … … 132 201 ar & BOOST_SERIALIZATION_NVP( size ); 133 202 ar & BOOST_SERIALIZATION_NVP( schedules ); 203 ar & BOOST_SERIALIZATION_NVP( sourceLines ); 134 204 135 205 // 読み込み後の処理 … … 163 233 ar & BOOST_SERIALIZATION_NVP( size ); 164 234 ar & BOOST_SERIALIZATION_NVP( schedules ); 235 ar & BOOST_SERIALIZATION_NVP( sourceLines ); 165 236 } 166 237 … … 192 263 Put( nativeCode, isOpBuffer ); 193 264 } 194 NativeCode( const char *codeBuffer, int size )265 NativeCode( const char *codeBuffer, int size, bool isOpBuffer ) 195 266 : allocateSize( 8192 ) 196 267 , codeBuffer( (char *)malloc( allocateSize ) ) 197 268 , size( 0 ) 198 269 { 199 Put( codeBuffer, size );270 Put( codeBuffer, size, isOpBuffer ); 200 271 } 201 272 ~NativeCode() … … 214 285 } 215 286 287 const char *GetCodeBuffer() const 288 { 289 return codeBuffer; 290 } 216 291 int GetSize() const 217 292 { … … 332 407 ObpPlus(); 333 408 } 409 410 void NextSourceLine(); 334 411 }; -
trunk/abdev/BasicCompiler_Common/src/Class.cpp
r259 r263 737 737 pUserProc=(UserProc *)pVtbl[i]; 738 738 if(!pUserProc) continue; 739 pVtbl[i]=pUserProc->_beginOpAddressOld+ImageBase+MemPos_CodeSection; 739 740 // 古いOpBufferを利用する場合は_beginOpAddressOldでないとダメ 741 //pVtbl[i]=pUserProc->_beginOpAddressOld+ImageBase+MemPos_CodeSection; 742 pVtbl[i]=pUserProc->GetBeginOpAddress()+ImageBase+MemPos_CodeSection; 740 743 } 741 744 } -
trunk/abdev/BasicCompiler_Common/src/Linker.cpp
r258 r263 26 26 if( schedule.GetType() == Schedule::DllProc ) 27 27 { 28 #ifdef _AMD64 28 #ifdef _AMD64_ 29 29 nativeCode.Overwrite( 30 30 schedule.GetOffset(), … … 103 103 void Linker::Link( vector<ObjectModule *> &objectModules ) 104 104 { 105 // nativeCodeは初期状態でなければならない 106 if( nativeCode.GetSize() > 0 ) 107 { 108 SetError(); 109 } 110 105 111 /* 106 112 BOOST_FOREACH( ObjectModule *pObjectModule, objectModules ) -
trunk/abdev/BasicCompiler_Common/src/NativeCode.cpp
r258 r263 22 22 long baseOffset = size; 23 23 24 // コードバッファを追加 24 25 Put( nativeCode.codeBuffer, nativeCode.size, isOpBuffer ); 25 26 27 // スケジュールを追加 26 28 BOOST_FOREACH( const Schedule &schedule, nativeCode.schedules ) 27 29 { … … 31 33 baseOffset + schedule.GetOffset(), 32 34 schedule.GetLongPtrValue() 35 ) 36 ); 37 } 38 39 // ソースコード行番号とネイティブコード位置の対応情報を追加 40 BOOST_FOREACH( const SourceLine &sourceLine, nativeCode.sourceLines ) 41 { 42 this->sourceLines.push_back( 43 SourceLine( 44 sourceLine.GetLineNum(), 45 baseOffset + sourceLine.GetNativeCodePos(), 46 sourceLine.GetSourceCodePos(), 47 sourceLine.GetCodeType() 33 48 ) 34 49 ); … … 85 100 ObpPlus( sizeof(long) ); 86 101 } 102 103 void NativeCode::NextSourceLine() 104 { 105 if( sourceLines.size() ) 106 { 107 if( sourceLines.back().GetNativeCodePos() == size ) 108 { 109 sourceLines.back().SetSourceCodePos( cp ); 110 return; 111 } 112 } 113 114 extern BOOL bDebugSupportProc; 115 extern BOOL bSystemProc; 116 DWORD sourceLineType = 0; 117 if( bDebugSupportProc ) 118 { 119 sourceLineType |= CODETYPE_DEBUGPROC; 120 } 121 if( bSystemProc ) 122 { 123 sourceLineType |= CODETYPE_SYSTEMPROC; 124 } 125 sourceLines.push_back( SourceLine( (long)sourceLines.size(), size, cp, sourceLineType ) ); 126 }
Note:
See TracChangeset
for help on using the changeset viewer.