- Timestamp:
- Jul 28, 2007, 4:17:56 PM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/Compile_ProcOp.cpp
r246 r247 413 413 414 414 //プロシージャ抜け出しスケジュール(Exit Sub/Function) 415 extern DWORD *pExitSubSchedule; 416 extern int ExitSubScheduleNum; 417 pExitSubSchedule=(DWORD *)HeapAlloc(hHeap,0,1); 418 ExitSubScheduleNum=0; 415 compiler.codeGenerator.exitSubCodePositions.clear(); 416 compiler.codeGenerator._exitSubCodePositions_ObpOld.clear(); 419 417 420 418 //ラベル用のメモリを確保 … … 620 618 621 619 //プロシージャ抜け出しスケジュール(Exit Sub/Function) 622 for(i3=0;i3<ExitSubScheduleNum;i3++){ 623 *((long *)(OpBuffer+pExitSubSchedule[i3]))=obp-(pExitSubSchedule[i3]+sizeof(long)); 624 } 625 HeapDefaultFree(pExitSubSchedule); 620 compiler.codeGenerator.ResolveExitSubSchedule(); 626 621 627 622 if(bDebugCompile&&bDebugSupportProc==0){ -
trunk/abdev/BasicCompiler32/Compile_Statement.cpp
r246 r247 580 580 void OpcodeDo(char *Parameter){ 581 581 extern HANDLE hHeap; 582 int i,i2,i3 ,i4;582 int i,i2,i3; 583 583 584 584 if(Parameter[0]) SetError(10,"Do",cp); … … 702 702 703 703 //jne 704 OpBuffer[obp++]=(char)0x0F; 705 OpBuffer[obp++]=(char)0x85; 706 obp+=sizeof(long); 707 i2=obp; 708 704 const CodeGenerator::PertialSchedule *pTempPertialSchedule1 = compiler.codeGenerator.op_jne( 0, sizeof(char), true ); 709 705 710 706 //cmp ebx,0 … … 712 708 713 709 //jne 714 OpBuffer[obp++]=(char)0x0F; 715 OpBuffer[obp++]=(char)0x85; 716 obp+=sizeof(long); 717 i4=obp; 718 710 const CodeGenerator::PertialSchedule *pTempPertialSchedule2 = compiler.codeGenerator.op_jne( 0, sizeof(char), true ); 719 711 720 712 if(basbuf[i3]=='0'){ … … 724 716 pDoPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(char), true ); 725 717 726 *((long *)(OpBuffer+i2-sizeof(long)))=obp-i2;727 *((long *)(OpBuffer+i4-sizeof(long)))=obp-i4;718 compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule1 ); 719 compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule2 ); 728 720 } 729 721 else if(basbuf[i3]=='1'){ … … 731 723 732 724 //jmp 2(ループを続ける) 733 OpBuffer[obp++]=(char)0xEB; 734 OpBuffer[obp++]=(char)0x02; 735 736 *((long *)(OpBuffer+i2-sizeof(long)))=obp-i2; 737 *((long *)(OpBuffer+i4-sizeof(long)))=obp-i4; 725 const CodeGenerator::PertialSchedule *pTempPertialSchedule3 = compiler.codeGenerator.op_jmp( 0, sizeof(char), true ); 726 727 compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule1 ); 728 compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule2 ); 738 729 739 730 //jmp 5(ループ終了) 740 731 pDoPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(char), true ); 732 733 compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule3 ); 741 734 } 742 735 } … … 791 784 792 785 void OpcodeExitSub(void){ 793 extern DWORD *pExitSubSchedule;794 extern int ExitSubScheduleNum;795 786 extern HANDLE hHeap; 796 787 … … 804 795 805 796 //jmp ...(End Sub/Function) 806 OpBuffer[obp++]=(char)0xE9; 807 808 pExitSubSchedule=(DWORD *)HeapReAlloc(hHeap,0,pExitSubSchedule,(ExitSubScheduleNum+1)*sizeof(DWORD)); 809 pExitSubSchedule[ExitSubScheduleNum]=obp; 810 ExitSubScheduleNum++; 811 812 obp+=sizeof(long); 797 compiler.codeGenerator.op_jmp_exitsub(); 813 798 } 814 799 -
trunk/abdev/BasicCompiler_Common/Compile.cpp
r246 r247 28 28 int CaseScheduleNum; 29 29 int NowCaseSchedule; 30 31 //プロシージャ抜け出しスケジュール(Exit Sub/Function)32 DWORD *pExitSubSchedule;33 int ExitSubScheduleNum;34 30 35 31 //グローバル変数初期バッファ -
trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
r246 r247 101 101 public: 102 102 103 // Exit Subスケジュールの管理 104 std::vector<long> exitSubCodePositions; 105 std::vector<int> _exitSubCodePositions_ObpOld; 106 103 107 // Gotoスケジュールの管理 104 108 std::vector<GotoLabelSchedule> gotoLabelSchedules; … … 158 162 return _continueCodePositions_ObpOld[_continueCodePositions_ObpOld.size()-1]; 159 163 } 164 165 void ResolveExitSubSchedule(); 160 166 161 167 void CheckUnresolveSchedule(); … … 183 189 const PertialSchedule *op_jmp( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false ); 184 190 void op_jmp_continue(); 191 void op_jmp_exitsub(); 185 192 void op_jmp_goto_schedule( const GotoLabelSchedule &gotoLabelSchedule ); 186 193 -
trunk/abdev/BasicCompiler_Common/src/CommonCodeGenerator.cpp
r246 r247 3 3 #include <CodeGenerator.h> 4 4 5 6 void CodeGenerator::ResolveExitSubSchedule() 7 { 8 BOOST_FOREACH( long exitSubCodePosition, exitSubCodePositions ) 9 { 10 pNativeCode->Overwrite( exitSubCodePosition, (long)( pNativeCode->GetSize()-(exitSubCodePosition+sizeof(long)) ) ); 11 } 12 13 // TODO: 未完成 14 BOOST_FOREACH( long exitSubCodePositionOld, _exitSubCodePositions_ObpOld ) 15 { 16 extern int obp; 17 pNativeCode->OverwriteOld( exitSubCodePositionOld, (long)( obp-(exitSubCodePositionOld+sizeof(long)) ) ); 18 } 19 } 5 20 6 21 void CodeGenerator::CheckUnresolveSchedule() … … 202 217 op_jmp( GetContinueCodePosOld()-obp, sizeof(long), false, true ); 203 218 } 204 void CodeGenerator::op_jmp_ goto_schedule( const GotoLabelSchedule &gotoLabelSchedule)219 void CodeGenerator::op_jmp_exitsub() 205 220 { 206 221 // オペコード 207 222 pNativeCode->Put( (char)0xE9 ); 208 223 224 exitSubCodePositions.push_back( pNativeCode->GetSize() ); 225 226 extern int obp; 227 _exitSubCodePositions_ObpOld.push_back( obp ); 228 229 pNativeCode->Put( (long)0 ); 230 } 231 void CodeGenerator::op_jmp_goto_schedule( const GotoLabelSchedule &gotoLabelSchedule ) 232 { 233 // オペコード 234 pNativeCode->Put( (char)0xE9 ); 235 209 236 gotoLabelSchedules.push_back( gotoLabelSchedule ); 210 237
Note:
See TracChangeset
for help on using the changeset viewer.