Changeset 242 in dev for trunk/abdev/BasicCompiler64/Compile_Statement.cpp
- Timestamp:
- Jul 27, 2007, 3:40:33 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler64/Compile_Statement.cpp
r226 r242 140 140 141 141 //comisd xmm0,qword ptr[data table offset] 142 OpBuffer[obp++]=(char)0x66; 143 OpBuffer[obp++]=(char)0x0F; 144 OpBuffer[obp++]=(char)0x2F; 145 OpBuffer[obp++]=(char)0x04; 146 OpBuffer[obp++]=(char)0x25; 147 *((long *)(OpBuffer+obp))=offset; 148 pobj_DataTableSchedule->add(); 149 obp+=sizeof(long); 142 compiler.codeGenerator.PutOld( 143 (char)0x66, 144 (char)0x0F, 145 (char)0x2F, 146 (char)0x04, 147 (char)0x25 148 ); 149 compiler.codeGenerator.PutOld( 150 (long)offset, 151 Schedule::DataTable 152 ); 150 153 } 151 154 else if(resultType.IsSingle()){ … … 154 157 155 158 //comiss xmm0,dword ptr[data table offset] 156 OpBuffer[obp++]=(char)0x0F; 157 OpBuffer[obp++]=(char)0x2F; 158 OpBuffer[obp++]=(char)0x04; 159 OpBuffer[obp++]=(char)0x25; 160 *((long *)(OpBuffer+obp))=offset; 161 pobj_DataTableSchedule->add(); 162 obp+=sizeof(long); 159 compiler.codeGenerator.PutOld( 160 (char)0x0F, 161 (char)0x2F, 162 (char)0x04, 163 (char)0x25 164 ); 165 compiler.codeGenerator.PutOld( 166 (long)offset, 167 Schedule::DataTable 168 ); 163 169 } 164 170 else{ … … 171 177 172 178 void OpcodeIf(char *Parameter){ 173 int i,i2,i3; 174 175 for(i=0;;i++){ 179 for(int i=0;;i++){ 176 180 if(Parameter[i]=='\0'){ 177 181 SetError(21,NULL,cp); … … 188 192 189 193 //je (endif、または else まで条件ジャンプ) 190 OpBuffer[obp++]=(char)0x0F; 191 OpBuffer[obp++]=(char)0x84; 192 obp+=sizeof(long); 193 194 //jeの番地 195 i3=obp; 194 CodeGenerator::PertialSchedule *pIfPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true ); 196 195 197 196 … … 203 202 GetLexicalScopes().Start( obp, SCOPE_TYPE_IF ); 204 203 205 i 2=CompileBuffer(ESC_ENDIF,0);204 int i2=CompileBuffer(ESC_ENDIF,0); 206 205 207 206 //レキシカルスコープをレベルダウン … … 211 210 if(i2==ESC_ELSE){ 212 211 //jmp (endifまで) 213 OpBuffer[obp++]=(char)0xE9; 214 obp+=sizeof(long); 215 216 *((long *)(OpBuffer+i3-sizeof(long)))=obp-i3; //ifからelseへのジャンプ先のオフセット値 217 218 i3=obp; 212 CodeGenerator::PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true ); 213 214 compiler.codeGenerator.opfix_JmpPertialSchedule( pIfPertialSchedule ); 215 219 216 220 217 … … 232 229 233 230 234 *((long *)(OpBuffer+i3-sizeof(long)))=obp-i3; //jmpジャンプ先のオフセット値231 compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule ); 235 232 } 236 233 else{ 237 *((long *)(OpBuffer+i3-sizeof(long)))=obp-i3; //jeジャンプ先のオフセット値234 compiler.codeGenerator.opfix_JmpPertialSchedule( pIfPertialSchedule ); 238 235 } 239 236 } … … 304 301 305 302 //Continueアドレスのバックアップとセット 306 extern DWORD dwContinueAddress; 307 DWORD dwTempContinue; 308 dwTempContinue=dwContinueAddress; 309 dwContinueAddress=obp; 310 pobj_TempSchedule->lock((int *)&dwTempContinue); 311 pobj_TempSchedule->lock((int *)&dwContinueAddress); 303 compiler.codeGenerator.ContinueAreaBegin(); 312 304 313 305 if(!Parameter[0]) SetError(10,"While",cp); … … 317 309 318 310 //je (Wend まで) 319 OpBuffer[obp++]=(char)0x0F; 320 OpBuffer[obp++]=(char)0x84; 321 obp+=sizeof(long); 322 323 //実行中の番地 324 int je_schedule=obp; 325 pobj_TempSchedule->lock(&je_schedule); 311 CodeGenerator::PertialSchedule *pWhilePertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true ); 326 312 327 313 //レキシカルスコープをレベルアップ … … 334 320 335 321 //jmp ... 336 OpBuffer[obp++]=(char)0xE9; 337 *((long *)(OpBuffer+obp))=dwContinueAddress-(obp+sizeof(long)); 338 obp+=sizeof(long); 339 pobj_TempSchedule->unlock(); 340 pobj_TempSchedule->unlock(); 322 compiler.codeGenerator.op_jmp_continue(); 341 323 342 324 //レキシカルスコープをレベルダウン 343 325 GetLexicalScopes().End(); 344 326 345 *((long *)(OpBuffer+je_schedule-sizeof(long)))=obp-je_schedule; //jeジャンプ先のオフセット値 346 pobj_TempSchedule->unlock(); 327 compiler.codeGenerator.opfix_JmpPertialSchedule( pWhilePertialSchedule ); 347 328 348 329 //Continueアドレスを復元 349 dwContinueAddress=dwTempContinue;330 compiler.codeGenerator.ContinueAreaEnd(); 350 331 } 351 332 … … 354 335 extern HANDLE hHeap; 355 336 Type resultType; 356 int i,i2 ,i3;337 int i,i2; 357 338 char temporary[VN_SIZE],variable[VN_SIZE],JudgeNum[VN_SIZE],StepNum[VN_SIZE]; 358 339 bool isError = false; … … 383 364 384 365 //jmp ... 385 OpBuffer[obp++]=(char)0xE9; 386 i2=obp; 387 obp+=sizeof(long); 366 CodeGenerator::PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true ); 388 367 389 368 //Continueアドレスのバックアップとセット 390 extern DWORD dwContinueAddress; 391 DWORD dwTempContinue; 392 dwTempContinue=dwContinueAddress; 393 dwContinueAddress=obp; 394 pobj_TempSchedule->lock((int *)&dwTempContinue); 395 pobj_TempSchedule->lock((int *)&dwContinueAddress); 369 compiler.codeGenerator.ContinueAreaBegin(); 396 370 397 371 //第2パラメータを取得(to~) … … 409 383 OpcodeCalc(temporary); 410 384 411 *((long *)(OpBuffer+i2))=obp-(i2+sizeof(long));385 compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule ); 412 386 413 387 //増加か減少かを区別する … … 424 398 425 399 //je [カウンタ減少の場合の判定] 426 OpBuffer[obp++]=(char)0x0F; 427 OpBuffer[obp++]=(char)0x84; 428 i2=obp; 429 obp+=sizeof(long); 400 pTempPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true ); 430 401 431 402 //判定(カウンタ増加の場合) … … 436 407 437 408 //jmp [カウンタ減少の場合の判定を飛び越す] 438 OpBuffer[obp++]=(char)0xE9; 439 i3=obp; 440 obp+=sizeof(long); 441 442 *((long *)(OpBuffer+i2))=obp-(i2+sizeof(long)); //jeジャンプ先のオフセット値 409 CodeGenerator::PertialSchedule *pTempPertialSchedule2 = compiler.codeGenerator.op_jmp( 0, sizeof(long), true ); 410 411 //jeジャンプ先のオフセット値 412 compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule ); 443 413 444 414 //判定(カウンタ減少の場合) … … 448 418 NumOpe(®,temporary,Type(),resultType); 449 419 450 *((long *)(OpBuffer+i3))=obp-(i3+sizeof(long)); //jmpジャンプ先のオフセット値 420 //jmpジャンプ先のオフセット値 421 compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule2 ); 451 422 452 423 //cmp rax,0 … … 456 427 457 428 //je ... 458 OpBuffer[obp++]=(char)0x0F; 459 OpBuffer[obp++]=(char)0x84; 460 int je_schedule=obp; 461 obp+=sizeof(long); 462 pobj_TempSchedule->lock(&je_schedule); 429 pTempPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true ); 463 430 464 431 //レキシカルスコープをレベルアップ … … 477 444 478 445 //jmp ... 479 OpBuffer[obp++]=(char)0xE9; 480 *((long *)(OpBuffer+obp))=dwContinueAddress-(obp+sizeof(long)); 481 obp+=sizeof(long); 482 if( isError == false ){ 483 pobj_TempSchedule->unlock(); 484 pobj_TempSchedule->unlock(); 485 } 446 compiler.codeGenerator.op_jmp_continue(); 486 447 487 448 //レキシカルスコープをレベルダウン 488 449 GetLexicalScopes().End(); 489 450 490 *((long *)(OpBuffer+je_schedule))=obp-(je_schedule+sizeof(long));//jeジャンプ先のオフセット値491 pobj_TempSchedule->unlock();451 //jeジャンプ先のオフセット値 452 compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule ); 492 453 493 454 //Continueアドレスを復元 494 dwContinueAddress=dwTempContinue;455 compiler.codeGenerator.ContinueAreaEnd(); 495 456 } 496 457 … … 502 463 503 464 //Continueアドレスのバックアップとセット 504 extern DWORD dwContinueAddress; 505 DWORD dwTempContinue; 506 dwTempContinue=dwContinueAddress; 507 dwContinueAddress=obp; 508 pobj_TempSchedule->lock((int *)&dwTempContinue); 509 pobj_TempSchedule->lock((int *)&dwContinueAddress); 465 compiler.codeGenerator.ContinueAreaBegin(); 510 466 511 467 //レキシカルスコープをレベルアップ … … 516 472 517 473 GetLexicalScopes().CallDestructorsOfScopeEnd(); 474 475 CodeGenerator::PertialSchedule *pDoPertialSchedule = NULL; 518 476 519 477 extern char *basbuf; … … 543 501 544 502 //je 5(ループ終了) 545 OpBuffer[obp++]=(char)0x74; 546 OpBuffer[obp++]=(char)0x05; 503 pDoPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(char), true ); 547 504 } 548 505 else if(basbuf[i3]=='1'){ … … 550 507 551 508 //jne 5(ループ終了) 552 OpBuffer[obp++]=(char)0x75; 553 OpBuffer[obp++]=(char)0x05; 509 pDoPertialSchedule = compiler.codeGenerator.op_jne( 0, sizeof(char), true ); 554 510 } 555 511 break; … … 558 514 559 515 //jmp ... 560 OpBuffer[obp++]=(char)0xE9; 561 *((long *)(OpBuffer+obp))=dwContinueAddress-(obp+sizeof(long)); 562 obp+=sizeof(long); 563 pobj_TempSchedule->unlock(); 564 pobj_TempSchedule->unlock(); 516 compiler.codeGenerator.op_jmp_continue(); 517 518 if( pDoPertialSchedule ) 519 { 520 compiler.codeGenerator.opfix_JmpPertialSchedule( pDoPertialSchedule ); 521 } 565 522 566 523 //jmp ... … … 568 525 int je_schedule=obp; 569 526 obp+=sizeof(long); 570 pobj_TempSchedule->lock(&je_schedule);571 527 572 528 //レキシカルスコープをレベルダウン … … 574 530 575 531 *((long *)(OpBuffer+je_schedule))=obp-(je_schedule+sizeof(long)); //jmpジャンプ先のオフセット値 576 pobj_TempSchedule->unlock();577 532 578 533 //Continueアドレスを復元 579 dwContinueAddress=dwTempContinue;534 compiler.codeGenerator.ContinueAreaEnd(); 580 535 } 581 536 void OpcodeContinue(void){ 582 extern DWORD dwContinueAddress;583 584 if(dwContinueAddress==-1){585 SetError(12,"Continue",cp);586 return;587 }588 589 537 //jmp ...(Continue addr) 590 OpBuffer[obp++]=(char)0xE9; 591 592 *((long *)(OpBuffer+obp))=dwContinueAddress-(obp+sizeof(long)); 593 obp+=sizeof(long); 538 compiler.codeGenerator.op_jmp_continue(); 594 539 } 595 540
Note:
See TracChangeset
for help on using the changeset viewer.