Changeset 34 in dev for BasicCompiler64/Compile_Statement.cpp
- Timestamp:
- Jan 14, 2007, 6:11:23 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler64/Compile_Statement.cpp
r31 r34 191 191 192 192 //レキシカルスコープをレベルアップ 193 obj_LexScopes. LevelUp(obp);193 obj_LexScopes.Start( obp, SCOPE_TYPE_IF ); 194 194 195 195 i2=CompileBuffer(ESC_ENDIF,0); 196 196 197 197 //レキシカルスコープをレベルダウン 198 obj_LexScopes. LevelDown();198 obj_LexScopes.End(); 199 199 200 200 … … 215 215 216 216 //レキシカルスコープをレベルアップ 217 obj_LexScopes. LevelUp(obp);217 obj_LexScopes.Start( obp, SCOPE_TYPE_IF ); 218 218 219 219 CompileBuffer(ESC_ENDIF,0); 220 220 221 221 //レキシカルスコープをレベルダウン 222 obj_LexScopes. LevelDown();222 obj_LexScopes.End(); 223 223 224 224 … … 292 292 } 293 293 void OpcodeWhile(char *Parameter){ 294 extern DWORD *pExitWhileSchedule;295 extern int ExitWhileScheduleNum;296 294 extern HANDLE hHeap; 297 295 int i2; 298 DWORD *lpdwTemp;299 int TempNum;300 296 301 297 //Continueアドレスのバックアップとセット … … 321 317 pobj_TempSchedule->lock(&je_schedule); 322 318 323 //ExitWhileスケジュールの準備324 lpdwTemp=pExitWhileSchedule;325 TempNum=ExitWhileScheduleNum;326 pExitWhileSchedule=(DWORD *)HeapAlloc(hHeap,0,1);327 ExitWhileScheduleNum=0;328 329 319 //レキシカルスコープをレベルアップ 330 obj_LexScopes. LevelUp(obp);320 obj_LexScopes.Start( obp, SCOPE_TYPE_WHILE ); 331 321 332 322 //While内をコンパイル 333 323 CompileBuffer(0,COM_WEND); 334 324 335 CallDestrouctorsOfScope();325 obj_LexScopes.CallDestructorsOfScopeEnd(); 336 326 337 327 //jmp ... … … 342 332 pobj_TempSchedule->unlock(); 343 333 344 //ExitWhileスケジュール345 for(i2=0;i2<ExitWhileScheduleNum;i2++){346 *((long *)(OpBuffer+pExitWhileSchedule[i2]))=obp-(pExitWhileSchedule[i2]+sizeof(long));347 }348 HeapDefaultFree(pExitWhileSchedule);349 pExitWhileSchedule=lpdwTemp;350 ExitWhileScheduleNum=TempNum;351 352 334 //レキシカルスコープをレベルダウン 353 obj_LexScopes. LevelDown();335 obj_LexScopes.End(); 354 336 355 337 *((long *)(OpBuffer+je_schedule-sizeof(long)))=obp-je_schedule; //jeジャンプ先のオフセット値 … … 359 341 dwContinueAddress=dwTempContinue; 360 342 } 361 void OpcodeExitWhile(void){ 362 extern DWORD *pExitWhileSchedule; 363 extern int ExitWhileScheduleNum; 364 extern HANDLE hHeap; 365 366 if(!pExitWhileSchedule){ 367 SetError(12,"Exit While",cp); 368 return; 369 } 370 371 //jmp ...(Wend addr) 372 OpBuffer[obp++]=(char)0xE9; 373 374 pExitWhileSchedule=(DWORD *)HeapReAlloc(hHeap,0,pExitWhileSchedule,(ExitWhileScheduleNum+1)*sizeof(DWORD)); 375 pExitWhileSchedule[ExitWhileScheduleNum]=obp; 376 ExitWhileScheduleNum++; 377 378 obp+=sizeof(long); 379 } 343 380 344 char szNextVariable[VN_SIZE]; 381 345 void OpcodeFor(char *Parameter){ 382 extern DWORD *pExitForSchedule;383 extern int ExitForScheduleNum;384 346 extern HANDLE hHeap; 385 DWORD *lpdwTemp;386 int TempNum;387 347 int i,i2,i3; 388 348 char temporary[VN_SIZE],variable[VN_SIZE],JudgeNum[VN_SIZE],StepNum[VN_SIZE]; 349 bool isError = false; 389 350 390 351 //第1パラメータを取得 … … 392 353 if(!Parameter[i]){ 393 354 SetError(12,"For",cp); 355 isError = true; 394 356 goto ErrorStep; 395 357 } … … 405 367 if(temporary[i2]=='\0'){ 406 368 SetError(12,"For",cp); 369 isError = true; 407 370 goto ErrorStep; 408 371 } … … 488 451 pobj_TempSchedule->lock(&je_schedule); 489 452 490 //ExitForスケジュールの準備491 lpdwTemp=pExitForSchedule;492 TempNum=ExitForScheduleNum;493 pExitForSchedule=(DWORD *)HeapAlloc(hHeap,0,1);494 ExitForScheduleNum=0;495 496 453 //レキシカルスコープをレベルアップ 497 obj_LexScopes. LevelUp(obp);454 obj_LexScopes.Start( obp, SCOPE_TYPE_FOR ); 498 455 499 456 //For内をコンパイル 500 457 CompileBuffer(0,COM_NEXT); 501 458 502 CallDestrouctorsOfScope();459 obj_LexScopes.CallDestructorsOfScopeEnd(); 503 460 504 461 if(szNextVariable[0]){ … … 512 469 *((long *)(OpBuffer+obp))=dwContinueAddress-(obp+sizeof(long)); 513 470 obp+=sizeof(long); 514 pobj_TempSchedule->unlock(); 515 pobj_TempSchedule->unlock(); 516 517 //ExitForスケジュール 518 for(i=0;i<ExitForScheduleNum;i++){ 519 *((long *)(OpBuffer+pExitForSchedule[i]))=obp-(pExitForSchedule[i]+sizeof(long)); 520 } 521 HeapDefaultFree(pExitForSchedule); 522 pExitForSchedule=lpdwTemp; 523 ExitForScheduleNum=TempNum; 471 if( isError == false ){ 472 pobj_TempSchedule->unlock(); 473 pobj_TempSchedule->unlock(); 474 } 524 475 525 476 //レキシカルスコープをレベルダウン 526 obj_LexScopes. LevelDown();477 obj_LexScopes.End(); 527 478 528 479 *((long *)(OpBuffer+je_schedule))=obp-(je_schedule+sizeof(long)); //jeジャンプ先のオフセット値 … … 532 483 dwContinueAddress=dwTempContinue; 533 484 } 534 void OpcodeExitFor(void){535 extern DWORD *pExitForSchedule;536 extern int ExitForScheduleNum;537 extern HANDLE hHeap;538 539 if(!pExitForSchedule){540 SetError(12,"Exit For",cp);541 return;542 }543 544 //jmp ...(Next addr)545 OpBuffer[obp++]=(char)0xE9;546 547 pExitForSchedule=(DWORD *)HeapReAlloc(hHeap,0,pExitForSchedule,(ExitForScheduleNum+1)*sizeof(DWORD));548 pExitForSchedule[ExitForScheduleNum]=obp;549 ExitForScheduleNum++;550 551 obp+=sizeof(long);552 }553 485 554 486 void OpcodeDo(char *Parameter){ 555 extern DWORD *pExitDoSchedule;556 extern int ExitDoScheduleNum;557 487 extern HANDLE hHeap; 558 488 int i,i2,i3; 559 DWORD *lpdwTemp;560 int TempNum;561 489 562 490 if(Parameter[0]) SetError(10,"Do",cp); 563 564 //ExitDoスケジュールの準備565 lpdwTemp=pExitDoSchedule;566 TempNum=ExitDoScheduleNum;567 pExitDoSchedule=(DWORD *)HeapAlloc(hHeap,0,1);568 ExitDoScheduleNum=0;569 491 570 492 //Continueアドレスのバックアップとセット … … 577 499 578 500 //レキシカルスコープをレベルアップ 579 obj_LexScopes. LevelUp(obp);501 obj_LexScopes.Start( obp, SCOPE_TYPE_DO ); 580 502 581 503 //Do内をコンパイル 582 504 CompileBuffer(0,COM_LOOP); 583 505 584 CallDestrouctorsOfScope();506 obj_LexScopes.CallDestructorsOfScopeEnd(); 585 507 586 508 extern char *basbuf; … … 637 559 pobj_TempSchedule->lock(&je_schedule); 638 560 639 //ExitDoスケジュール640 for(i=0;i<ExitDoScheduleNum;i++){641 *((long *)(OpBuffer+pExitDoSchedule[i]))=obp-(pExitDoSchedule[i]+sizeof(long));642 }643 HeapDefaultFree(pExitDoSchedule);644 pExitDoSchedule=lpdwTemp;645 ExitDoScheduleNum=TempNum;646 647 561 //レキシカルスコープをレベルダウン 648 obj_LexScopes. LevelDown();562 obj_LexScopes.End(); 649 563 650 564 *((long *)(OpBuffer+je_schedule))=obp-(je_schedule+sizeof(long)); //jmpジャンプ先のオフセット値 … … 653 567 //Continueアドレスを復元 654 568 dwContinueAddress=dwTempContinue; 655 }656 void OpcodeExitDo(void){657 extern HANDLE hHeap;658 extern DWORD *pExitDoSchedule;659 extern int ExitDoScheduleNum;660 661 if(!pExitDoSchedule){662 SetError(12,"Exit Do",cp);663 return;664 }665 666 //jmp ...(Loop addr)667 OpBuffer[obp++]=(char)0xE9;668 669 pExitDoSchedule=(DWORD *)HeapReAlloc(hHeap,0,pExitDoSchedule,(ExitDoScheduleNum+1)*sizeof(DWORD));670 pExitDoSchedule[ExitDoScheduleNum]=obp;671 ExitDoScheduleNum++;672 673 obp+=sizeof(long);674 569 } 675 570 void OpcodeContinue(void){ … … 698 593 return; 699 594 } 595 596 //未解放のローカルオブジェクトのデストラクタを呼び出す 597 obj_LexScopes.CallDestructorsOfReturn(); 700 598 701 599 //jmp ...(End Sub/Function) … … 938 836 939 837 //レキシカルスコープをレベルアップ 940 obj_LexScopes. LevelUp(obp);838 obj_LexScopes.Start( obp, SCOPE_TYPE_SELECT ); 941 839 942 840 //Select Case内をコンパイル … … 955 853 956 854 //レキシカルスコープをレベルダウン 957 obj_LexScopes. LevelDown();855 obj_LexScopes.End(); 958 856 959 857 pCaseSchedule=temp_pCaseSchedule; … … 1051 949 extern BOOL bCompilingGlobal; 1052 950 if(bCompilingGlobal){ 1053 //Gosub~Returnとして扱う 1054 1055 //mov rax,qword ptr[rsp+offset] ※スタックフレームを利用 1056 pobj_sf->push(REG_NON); 1057 pobj_sf->ref(REG_RAX); 1058 pobj_sf->pop(REG_NON); 1059 1060 //jmp rax 1061 OpBuffer[obp++]=(char)0xFF; 1062 OpBuffer[obp++]=(char)0xE0; 951 SetError(62,NULL,cp); 1063 952 } 1064 953 else{
Note:
See TracChangeset
for help on using the changeset viewer.