Changeset 262 in dev for trunk/abdev/BasicCompiler64
- Timestamp:
- Aug 4, 2007, 4:36:34 AM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler64
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler64/CodeGenerator.cpp
r255 r262 1695 1695 1696 1696 void CodeGenerator::op_call( const UserProc *pUserProc ){ 1697 pUserProc->Using(); 1698 1699 pNativeCode->Put( (char)0xE8 ); 1700 pobj_SubAddrSchedule->add( pUserProc, 1 ); 1701 pNativeCode->Put( (long)0 ); 1697 pNativeCode->Put( (char)0xE8 ); 1698 pNativeCode->PutUserProcSchedule( pUserProc, true ); 1702 1699 } 1703 1700 void CodeGenerator::op_call( const DllProc *pDllProc ){ 1704 pDllProc->Using(); 1705 1706 pNativeCode->Put( (char)0xFF ); 1707 pNativeCode->Put( (char)0x15 ); 1708 pobj_ImportAddrSchedule->add(pDllProc); 1709 pNativeCode->Put( (long)0 ); 1701 pNativeCode->Put( (char)0xFF ); 1702 pNativeCode->Put( (char)0x15 ); 1703 pNativeCode->PutDllProcSchedule( pDllProc ); 1710 1704 } 1711 1705 void CodeGenerator::op_ret(){ 1712 1706 pNativeCode->Put( (char)0xC3 ); 1713 1707 } 1708 void CodeGenerator::op_addressof( int reg, const UserProc *pUserProc ) 1709 { 1710 //mov reg,userProcAddress 1711 1712 //オペコード、レジスタ 1713 pNativeCode->Put( (char)(0xB8|REGISTER_OPERAND(reg)) ); 1714 1715 //DISP32 1716 pNativeCode->PutUserProcSchedule( pUserProc, false ); 1717 } -
trunk/abdev/BasicCompiler64/Compile_Func.cpp
r257 r262 159 159 160 160 //mov rax,ProcAddr 161 compiler.codeGenerator.op_mov_RV(sizeof(_int64),REG_RAX,0); 162 obp-=sizeof(long); 163 pobj_SubAddrSchedule->add(pUserProc,0); 164 obp+=sizeof(long); 161 compiler.codeGenerator.op_addressof( REG_RAX, pUserProc ); 165 162 } 166 163 -
trunk/abdev/BasicCompiler64/Compile_Object.cpp
r255 r262 16 16 //をセットしておかなければならない 17 17 18 int jnz_back;19 20 18 21 19 //jnzの番地 22 jnz_back=obp; 20 /*extern int obp; 21 int jnz_back = obp;*/ 23 22 24 23 if(bSomeObjects){ 25 24 SetError(); 26 25 //mov qword ptr[rsp+offset],rbx ※スタックフレームを利用 27 pobj_sf->push(REG_RBX);26 //pobj_sf->push(REG_RBX); 28 27 29 28 // ※ここでプッシュされた値はコンストラクタのthisポインタとなる 30 29 //mov qword ptr[rsp+offset],rax ※スタックフレームを利用 31 pobj_sf->push(REG_RAX);30 //pobj_sf->push(REG_RAX); 32 31 } 33 32 … … 73 72 74 73 if(bSomeObjects){ 74 /* 75 75 //mov rax,qword ptr[rsp+offset] ※スタックフレームを利用 76 76 pobj_sf->pop(REG_RAX); … … 87 87 //jnz ↑ 88 88 compiler.codeGenerator.op_jne( jnz_back-obp, sizeof(long), false, true ); 89 */ 89 90 } 90 91 } … … 180 181 181 182 //mov rcx,DestructorProcAddr(デストラクタの関数ポインタ) 182 compiler.codeGenerator.op_mov_RV(sizeof(_int64),REG_RCX,0); 183 obp-=sizeof(long); 184 pobj_SubAddrSchedule->add(&method->GetUserProc(),0); 185 method->GetUserProc().Using(); 186 obp+=sizeof(long); 183 compiler.codeGenerator.op_addressof( REG_RCX, &method->GetUserProc() ); 187 184 188 185 //mov qword ptr[rax],rcx -
trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp
r259 r262 237 237 238 238 //ラベル用のメモリを確保 239 extern LABEL *pLabelNames; 240 extern int MaxLabelNum; 241 pLabelNames=(LABEL *)HeapAlloc(hHeap,0,1); 242 MaxLabelNum=0; 239 compiler.codeGenerator.gotoLabels.clear(); 243 240 244 241 //Gotoラベルスケジュール … … 565 562 } 566 563 567 //ラベル用のメモリを解放568 for(i3=0;i3<MaxLabelNum;i3++){569 if(pLabelNames[i3].pName) HeapDefaultFree(pLabelNames[i3].pName);570 }571 HeapDefaultFree(pLabelNames);572 573 564 //With情報のメモリを解放 574 565 for(i3=0;i3<WithInfo.num;i3++){ -
trunk/abdev/BasicCompiler64/Compile_Statement.cpp
r257 r262 236 236 237 237 int GetLabelAddress(char *LabelName,int LineNum){ 238 extern int MaxLabelNum;239 extern LABEL *pLabelNames;240 int i;241 242 238 if(LabelName){ 243 for(i=0;i<MaxLabelNum;i++){ 244 if(pLabelNames[i].pName){ 245 if(lstrcmp(LabelName,pLabelNames[i].pName)==0) return pLabelNames[i].address; 239 BOOST_FOREACH( const GotoLabel &label, compiler.codeGenerator.gotoLabels ) 240 { 241 if( label.name.size() > 0 ) 242 { 243 if( label.name == LabelName ) 244 { 245 return label.address; 246 } 246 247 } 247 248 } 248 249 } 249 250 else{ 250 for(i=0;i<MaxLabelNum;i++){ 251 if(pLabelNames[i].pName==0){ 252 if(LineNum==pLabelNames[i].line) return pLabelNames[i].address; 251 BOOST_FOREACH( const GotoLabel &label, compiler.codeGenerator.gotoLabels ) 252 { 253 if( label.name.size() == 0 ) 254 { 255 if( label.line == LineNum ) 256 { 257 return label.address; 258 } 253 259 } 254 260 } -
trunk/abdev/BasicCompiler64/MakePeHdr.cpp
r259 r262 361 361 } 362 362 363 //ラベル用のメモリを確保 364 extern LABEL *pLabelNames; 365 extern int MaxLabelNum; 366 pLabelNames=(LABEL *)HeapAlloc(hHeap,0,1); 367 MaxLabelNum=0; 363 //ラベル管理オブジェクトを初期化 364 compiler.codeGenerator.gotoLabels.clear(); 368 365 369 366 //Gotoラベルスケジュール … … 411 408 //グローバル実行領域をコンパイル開始 412 409 CompileBuffer(0,0); 413 414 //ラベル用のメモリを解放415 for(i=0;i<MaxLabelNum;i++){416 if(pLabelNames[i].pName) HeapDefaultFree(pLabelNames[i].pName);417 }418 HeapDefaultFree(pLabelNames);419 410 420 411 //Goto未知ラベルスケジュールが存在したらエラーにする -
trunk/abdev/BasicCompiler64/Opcode.h
r255 r262 20 20 21 21 #define breakpoint compiler.codeGenerator.PutOld( (char)0xCC ); 22 23 24 //ラベルアドレス25 struct LABEL{26 char *pName;27 int line;28 DWORD address;29 };30 22 31 23
Note:
See TracChangeset
for help on using the changeset viewer.