Changeset 96 in dev for BasicCompiler32
- Timestamp:
- Apr 15, 2007, 2:48:08 AM (18 years ago)
- Location:
- BasicCompiler32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler32/Compile_Set_Var.cpp
r75 r96 8 8 9 9 void SetStructVariable( const Type &varType, const Type &calcType, BOOL bUseHeap){ 10 /*11 TODO: 消す12 ///////////////////////////////////////////////////////////////////13 // オペレータ '=' のオーバーロード関数を呼ぶ14 ///////////////////////////////////////////////////////////////////15 16 int type[10];17 LONG_PTR index_stack[10];18 BOOL array_bUseHeap[10];19 int sp=2;20 21 //左辺22 type[0]=DEF_OBJECT;23 index_stack[0]=lpVarIndex;24 array_bUseHeap[0]=0;25 26 //右辺27 type[1]=CalcType;28 index_stack[1]=lpCalcIndex;29 array_bUseHeap[1]=bUseHeap;30 31 int iRet;32 iRet=CallOperatorProc(CALC_SUBSITUATION,NULL,type,index_stack,array_bUseHeap,sp);33 if(iRet==-1||iRet==1){34 //成功したとき、またはエラーが発行されたとき35 return;36 }*/37 38 39 10 if( calcType.IsStruct() ){ 40 11 if( varType.GetClass().IsEquals( &calcType.GetClass() ) ){ //等しい … … 411 382 } 412 383 } 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 /*439 TODO: 消す440 void SetDoubleVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset){441 ChangeTypeToDouble(type);442 443 //pop ebx444 op_pop(REG_EBX);445 446 //pop eax447 op_pop(REG_EAX);448 449 if(VarKind==VAR_GLOBAL){450 if(bOffsetOffset){451 //mov dword ptr[ecx+offset],ebx452 OpBuffer[obp++]=(char)0x89;453 OpBuffer[obp++]=(char)0x99;454 *((long *)(OpBuffer+obp))=offset;455 pobj_GlobalVarSchedule->add();456 obp+=sizeof(long);457 458 //mov dword ptr[ecx+offset+sizeof(long)],eax459 OpBuffer[obp++]=(char)0x89;460 OpBuffer[obp++]=(char)0x81;461 *((long *)(OpBuffer+obp))=offset+sizeof(long);462 pobj_GlobalVarSchedule->add();463 obp+=sizeof(long);464 }465 else{466 //mov dword ptr[offset],ebx467 OpBuffer[obp++]=(char)0x89;468 OpBuffer[obp++]=(char)0x1D;469 *((long *)(OpBuffer+obp))=offset;470 pobj_GlobalVarSchedule->add();471 obp+=sizeof(long);472 473 //mov dword ptr[offset+sizeof(long)],eax474 OpBuffer[obp++]=(char)0xA3;475 *((long *)(OpBuffer+obp))=offset+sizeof(long);476 pobj_GlobalVarSchedule->add();477 obp+=sizeof(long);478 }479 }480 else if( VarKind==VAR_REFGLOBAL ){481 SetError(300,NULL,cp);482 }483 else if(VarKind==VAR_LOCAL){484 if(bOffsetOffset){485 //add ecx,offset486 OpBuffer[obp++]=(char)0x81;487 OpBuffer[obp++]=(char)0xC1;488 *((long *)(OpBuffer+obp))=offset;489 AddLocalVarAddrSchedule();490 obp+=sizeof(long);491 492 //mov dword ptr[ebp+ecx],ebx493 OpBuffer[obp++]=(char)0x89;494 OpBuffer[obp++]=(char)0x5C;495 OpBuffer[obp++]=(char)0x0D;496 OpBuffer[obp++]=(char)0x00;497 498 //add ecx,sizeof(long)499 OpBuffer[obp++]=(char)0x83;500 OpBuffer[obp++]=(char)0xC1;501 OpBuffer[obp++]=(char)0x04;502 503 //mov dword ptr[ebp+ecx],eax504 OpBuffer[obp++]=(char)0x89;505 OpBuffer[obp++]=(char)0x44;506 OpBuffer[obp++]=(char)0x0D;507 OpBuffer[obp++]=(char)0x00;508 }509 else{510 //mov dword ptr[ebp+offset],ebx511 OpBuffer[obp++]=(char)0x89;512 OpBuffer[obp++]=(char)0x9D;513 *((long *)(OpBuffer+obp))=offset;514 AddLocalVarAddrSchedule();515 obp+=sizeof(long);516 517 //mov dword ptr[ebp+offset+sizeof(long)],eax518 OpBuffer[obp++]=(char)0x89;519 OpBuffer[obp++]=(char)0x85;520 *((long *)(OpBuffer+obp))=offset+sizeof(long);521 AddLocalVarAddrSchedule();522 obp+=sizeof(long);523 }524 }525 else if(VarKind==VAR_REFLOCAL){526 if(bOffsetOffset){527 //add ecx,dword ptr[ebp+offset]528 OpBuffer[obp++]=(char)0x03;529 OpBuffer[obp++]=(char)0x8D;530 *((long *)(OpBuffer+obp))=offset;531 AddLocalVarAddrSchedule();532 obp+=sizeof(long);533 }534 else{535 //mov ecx,dword ptr[ebp+offset]536 OpBuffer[obp++]=(char)0x8B;537 OpBuffer[obp++]=(char)0x8D;538 *((long *)(OpBuffer+obp))=offset;539 AddLocalVarAddrSchedule();540 obp+=sizeof(long);541 }542 543 //mov dword ptr[ecx],ebx544 OpBuffer[obp++]=(char)0x89;545 OpBuffer[obp++]=(char)0x19;546 547 //mov dword ptr[ecx+sizeof(long)],eax548 OpBuffer[obp++]=(char)0x89;549 OpBuffer[obp++]=(char)0x41;550 OpBuffer[obp++]=(char)0x04;551 }552 else if(VarKind==VAR_DIRECTMEM){553 //mov dword ptr[ecx],ebx554 OpBuffer[obp++]=(char)0x89;555 OpBuffer[obp++]=(char)0x19;556 557 //mov dword ptr[ecx+sizeof(long)],eax558 OpBuffer[obp++]=(char)0x89;559 OpBuffer[obp++]=(char)0x41;560 OpBuffer[obp++]=(char)0x04;561 }562 }563 void SetSingleVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset){564 if(type==DEF_SINGLE){565 //32ビット変数としてそのままコピーする566 SetDWordVariable(DEF_DWORD,VarKind,offset,bOffsetOffset);567 return;568 }569 570 if(type==DEF_DOUBLE){571 //fld qword ptr[esp]572 op_fld_ptr_esp(DEF_DOUBLE);573 574 //add esp,8575 op_add_esp(8);576 }577 else if(type==DEF_INT64||type==DEF_QWORD){578 //64ビット整数579 580 //fild qword ptr[esp]581 op_fld_ptr_esp(DEF_INT64);582 583 //add esp,8584 op_add_esp(8);585 }586 else if(IsSignedType(type)){587 //符号あり整数588 589 //fild dword ptr[esp]590 op_fld_ptr_esp(DEF_LONG);591 592 //add esp,4593 op_add_esp(4);594 }595 else{596 if(!IsWholeNumberType(type)){597 //不正な型の場合598 SetError(9,NULL,cp);599 return;600 }601 602 //符号なし整数603 604 //pop eax605 op_pop(REG_EAX);606 607 //push 0608 op_push_V(0);609 610 //push eax611 op_push(REG_EAX);612 613 //fild qword ptr[esp]614 OpBuffer[obp++]=(char)0xDF;615 OpBuffer[obp++]=(char)0x2C;616 OpBuffer[obp++]=(char)0x24;617 618 //add esp,8619 op_add_esp(8);620 }621 622 if(VarKind==VAR_GLOBAL){623 if(bOffsetOffset){624 //fstp dword ptr[ecx+offset]625 OpBuffer[obp++]=(char)0xD9;626 OpBuffer[obp++]=(char)0x99;627 *((long *)(OpBuffer+obp))=offset;628 pobj_GlobalVarSchedule->add();629 obp+=sizeof(long);630 }631 else{632 //fstp dword ptr[offset]633 OpBuffer[obp++]=(char)0xD9;634 OpBuffer[obp++]=(char)0x1D;635 *((long *)(OpBuffer+obp))=offset;636 pobj_GlobalVarSchedule->add();637 obp+=sizeof(long);638 }639 }640 else if( VarKind==VAR_REFGLOBAL ){641 SetError(300,NULL,cp);642 }643 else if(VarKind==VAR_LOCAL){644 if(bOffsetOffset){645 //add ecx,offset646 OpBuffer[obp++]=(char)0x81;647 OpBuffer[obp++]=(char)0xC1;648 *((long *)(OpBuffer+obp))=offset;649 AddLocalVarAddrSchedule();650 obp+=sizeof(long);651 652 //fstp dword ptr[ebp+ecx]653 OpBuffer[obp++]=(char)0xD9;654 OpBuffer[obp++]=(char)0x5C;655 OpBuffer[obp++]=(char)0x0D;656 OpBuffer[obp++]=(char)0x00;657 }658 else{659 //fstp dword ptr[ebp+offset]660 OpBuffer[obp++]=(char)0xD9;661 OpBuffer[obp++]=(char)0x9D;662 *((long *)(OpBuffer+obp))=offset;663 AddLocalVarAddrSchedule();664 obp+=sizeof(long);665 }666 }667 else if(VarKind==VAR_REFLOCAL){668 //mov eax,dword ptr[ebp+offset]669 OpBuffer[obp++]=(char)0x8B;670 OpBuffer[obp++]=(char)0x85;671 *((long *)(OpBuffer+obp))=offset;672 AddLocalVarAddrSchedule();673 obp+=sizeof(long);674 675 if(bOffsetOffset){676 //add eax,ecx677 OpBuffer[obp++]=(char)0x03;678 OpBuffer[obp++]=(char)0xC1;679 }680 681 //fstp dword ptr[eax]682 OpBuffer[obp++]=(char)0xD9;683 OpBuffer[obp++]=(char)0x18;684 }685 else if(VarKind==VAR_DIRECTMEM){686 //fstp dword ptr[ecx]687 OpBuffer[obp++]=(char)0xD9;688 OpBuffer[obp++]=(char)0x19;689 }690 }691 void SetInt64Variable(int type,RELATIVE_VAR *pRelative){692 if(type==DEF_DOUBLE){693 //fld qword ptr[esp]694 op_fld_ptr_esp(DEF_DOUBLE);695 696 //fistp qword ptr[esp]697 fpu_cast();698 OpBuffer[obp++]=(char)0xDF;699 OpBuffer[obp++]=(char)0x3C;700 OpBuffer[obp++]=(char)0x24;701 fpu_cast_end();702 703 //pop eax704 op_pop(REG_EAX);705 706 //pop edx707 op_pop(REG_EDX);708 }709 else if(type==DEF_SINGLE){710 //fld dword ptr[esp]711 op_fld_ptr_esp(DEF_SINGLE);712 713 //sub esp,4714 op_sub_esp(4);715 716 //fistp qword ptr[esp]717 fpu_cast();718 OpBuffer[obp++]=(char)0xDF;719 OpBuffer[obp++]=(char)0x3C;720 OpBuffer[obp++]=(char)0x24;721 fpu_cast_end();722 723 //pop eax724 op_pop(REG_EAX);725 726 //pop edx727 op_pop(REG_EDX);728 }729 else if(type==DEF_INT64||type==DEF_QWORD){730 //pop eax731 op_pop(REG_EAX);732 733 //pop edx734 op_pop(REG_EDX);735 }736 else if(IsSignedType(type)){737 //符号拡張738 //edx:eax ← eax739 740 //pop eax741 op_pop(REG_EAX);742 743 //cdq744 op_cdq();745 }746 else{747 if(!IsWholeNumberType(type)){748 //不正な型の場合749 SetError(9,NULL,cp);750 return;751 }752 753 //符号拡張754 //edx=0:eax755 756 //pop eax757 op_pop(REG_EAX);758 759 //xor edx,edx760 op_zero_reg(REG_EDX);761 }762 763 if(pRelative->dwKind==VAR_GLOBAL){764 if(pRelative->bOffsetOffset){765 //mov dword ptr[ecx+offset],eax766 OpBuffer[obp++]=(char)0x89;767 OpBuffer[obp++]=(char)0x81;768 *((long *)(OpBuffer+obp))=pRelative->offset;769 pobj_GlobalVarSchedule->add();770 obp+=sizeof(long);771 772 //mov dword ptr[ecx+offset+sizeof(long)],edx773 OpBuffer[obp++]=(char)0x89;774 OpBuffer[obp++]=(char)0x91;775 *((long *)(OpBuffer+obp))=pRelative->offset+sizeof(long);776 pobj_GlobalVarSchedule->add();777 obp+=sizeof(long);778 }779 else{780 //mov dword ptr[offset],eax781 OpBuffer[obp++]=(char)0xA3;782 *((long *)(OpBuffer+obp))=pRelative->offset;783 pobj_GlobalVarSchedule->add();784 obp+=sizeof(long);785 786 //mov dword ptr[offset+sizeof(long)],edx787 OpBuffer[obp++]=(char)0x89;788 OpBuffer[obp++]=(char)0x15;789 *((long *)(OpBuffer+obp))=pRelative->offset+sizeof(DWORD);790 pobj_GlobalVarSchedule->add();791 obp+=sizeof(long);792 }793 }794 else if(pRelative->dwKind==VAR_REFLOCAL){795 if(pRelative->bOffsetOffset){796 //add ecx,dword ptr[offset]797 op_add_RM( sizeof(long), REG_ECX, REG_NON, (int)pRelative->offset, MOD_DISP32 );798 }799 else{800 //mov ecx,dword ptr[offset]801 op_mov_RM( sizeof(long), REG_ECX, REG_NON, (int)pRelative->offset, MOD_DISP32 );802 }803 obp-=sizeof(long);804 pobj_GlobalVarSchedule->add();805 obp+=sizeof(long);806 807 //mov dword ptr[ecx],eax808 OpBuffer[obp++]=(char)0x89;809 OpBuffer[obp++]=(char)0x01;810 811 //mov dword ptr[ecx+sizeof(long)],edx812 OpBuffer[obp++]=(char)0x89;813 OpBuffer[obp++]=(char)0x51;814 OpBuffer[obp++]=(char)0x04;815 }816 else if(pRelative->dwKind==VAR_LOCAL){817 if(pRelative->bOffsetOffset){818 //add ecx,offset819 OpBuffer[obp++]=(char)0x81;820 OpBuffer[obp++]=(char)0xC1;821 *((long *)(OpBuffer+obp))=pRelative->offset;822 AddLocalVarAddrSchedule();823 obp+=sizeof(long);824 825 //mov dword ptr[ebp+ecx],eax826 OpBuffer[obp++]=(char)0x89;827 OpBuffer[obp++]=(char)0x44;828 OpBuffer[obp++]=(char)0x0D;829 OpBuffer[obp++]=(char)0x00;830 831 //add ecx,sizeof(long)832 OpBuffer[obp++]=(char)0x83;833 OpBuffer[obp++]=(char)0xC1;834 OpBuffer[obp++]=(char)0x04;835 836 //mov dword ptr[ebp+ecx],edx837 OpBuffer[obp++]=(char)0x89;838 OpBuffer[obp++]=(char)0x54;839 OpBuffer[obp++]=(char)0x0D;840 OpBuffer[obp++]=(char)0x00;841 }842 else{843 //mov dword ptr[ebp+offset],eax844 OpBuffer[obp++]=(char)0x89;845 OpBuffer[obp++]=(char)0x85;846 *((long *)(OpBuffer+obp))=pRelative->offset;847 AddLocalVarAddrSchedule();848 obp+=sizeof(long);849 850 //mov dword ptr[ebp+offset+sizeof(long)],edx851 OpBuffer[obp++]=(char)0x89;852 OpBuffer[obp++]=(char)0x95;853 *((long *)(OpBuffer+obp))=pRelative->offset+sizeof(long);854 AddLocalVarAddrSchedule();855 obp+=sizeof(long);856 }857 }858 else if(pRelative->dwKind==VAR_REFLOCAL){859 if(pRelative->bOffsetOffset){860 //add ecx,dword ptr[ebp+offset]861 OpBuffer[obp++]=(char)0x03;862 OpBuffer[obp++]=(char)0x8D;863 *((long *)(OpBuffer+obp))=pRelative->offset;864 AddLocalVarAddrSchedule();865 obp+=sizeof(long);866 }867 else{868 //mov ecx,dword ptr[ebp+offset]869 OpBuffer[obp++]=(char)0x8B;870 OpBuffer[obp++]=(char)0x8D;871 *((long *)(OpBuffer+obp))=pRelative->offset;872 AddLocalVarAddrSchedule();873 obp+=sizeof(long);874 }875 876 //mov dword ptr[ecx],eax877 OpBuffer[obp++]=(char)0x89;878 OpBuffer[obp++]=(char)0x01;879 880 //mov dword ptr[ecx+sizeof(long)],edx881 OpBuffer[obp++]=(char)0x89;882 OpBuffer[obp++]=(char)0x51;883 OpBuffer[obp++]=(char)0x04;884 }885 else if(pRelative->dwKind==VAR_DIRECTMEM){886 //mov dword ptr[ecx],eax887 OpBuffer[obp++]=(char)0x89;888 OpBuffer[obp++]=(char)0x01;889 890 //mov dword ptr[ecx+sizeof(long)],edx891 OpBuffer[obp++]=(char)0x89;892 OpBuffer[obp++]=(char)0x51;893 OpBuffer[obp++]=(char)0x04;894 }895 }896 void SetDWordVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset){897 if(type==DEF_DOUBLE||type==DEF_SINGLE){898 if(type==DEF_DOUBLE){899 //fld qword ptr[esp]900 op_fld_ptr_esp(DEF_DOUBLE);901 }902 else if(type==DEF_SINGLE){903 //fld dword ptr[esp]904 op_fld_ptr_esp(DEF_SINGLE);905 906 //sub esp,4907 op_sub_esp(4);908 }909 910 //fistp qword ptr[esp]911 fpu_cast();912 OpBuffer[obp++]=(char)0xDF;913 OpBuffer[obp++]=(char)0x3C;914 OpBuffer[obp++]=(char)0x24;915 fpu_cast_end();916 917 //pop eax918 op_pop(REG_EAX);919 920 //add esp,4921 op_add_esp(4);922 }923 else if(type==DEF_INT64||type==DEF_QWORD){924 //pop eax925 op_pop(REG_EAX);926 927 //add esp,4928 op_add_esp(4);929 }930 else{931 if(!IsWholeNumberType(type)){932 //不正な型の場合933 SetError(9,NULL,cp);934 return;935 }936 937 ChangeTypeToWhole(type,DEF_LONG);938 939 //pop eax940 op_pop(REG_EAX);941 }942 943 if(VarKind==VAR_GLOBAL){944 if(bOffsetOffset){945 //mov dword ptr[ecx+offset],eax946 OpBuffer[obp++]=(char)0x89;947 OpBuffer[obp++]=(char)0x81;948 *((long *)(OpBuffer+obp))=offset;949 pobj_GlobalVarSchedule->add();950 obp+=sizeof(long);951 }952 else{953 //mov dword ptr[offset],eax954 OpBuffer[obp++]=(char)0xA3;955 *((long *)(OpBuffer+obp))=offset;956 pobj_GlobalVarSchedule->add();957 obp+=sizeof(long);958 }959 }960 else if(VarKind==VAR_REFGLOBAL){961 if(bOffsetOffset){962 //add ecx,dword ptr[offset]963 op_add_RM( sizeof(long), REG_ECX, REG_NON, (int)offset, MOD_DISP32 );964 }965 else{966 //mov ecx,dword ptr[offset]967 op_mov_RM( sizeof(long), REG_ECX, REG_NON, (int)offset, MOD_DISP32 );968 }969 obp-=sizeof(long);970 pobj_GlobalVarSchedule->add();971 obp+=sizeof(long);972 973 //mov dword ptr[ecx],eax974 OpBuffer[obp++]=(char)0x89;975 OpBuffer[obp++]=(char)0x01;976 }977 else if(VarKind==VAR_LOCAL){978 if(bOffsetOffset){979 //add ecx,offset980 OpBuffer[obp++]=(char)0x81;981 OpBuffer[obp++]=(char)0xC1;982 *((long *)(OpBuffer+obp))=offset;983 AddLocalVarAddrSchedule();984 obp+=sizeof(long);985 986 //mov dword ptr[ebp+ecx],eax987 OpBuffer[obp++]=(char)0x89;988 OpBuffer[obp++]=(char)0x44;989 OpBuffer[obp++]=(char)0x0D;990 OpBuffer[obp++]=(char)0x00;991 }992 else{993 //mov dword ptr[ebp+offset],eax994 OpBuffer[obp++]=(char)0x89;995 OpBuffer[obp++]=(char)0x85;996 *((long *)(OpBuffer+obp))=offset;997 AddLocalVarAddrSchedule();998 obp+=sizeof(long);999 }1000 }1001 else if(VarKind==VAR_REFLOCAL){1002 if(bOffsetOffset){1003 //add ecx,dword ptr[ebp+offset]1004 OpBuffer[obp++]=(char)0x03;1005 OpBuffer[obp++]=(char)0x8D;1006 *((long *)(OpBuffer+obp))=offset;1007 AddLocalVarAddrSchedule();1008 obp+=sizeof(long);1009 }1010 else{1011 //mov ecx,dword ptr[ebp+offset]1012 OpBuffer[obp++]=(char)0x8B;1013 OpBuffer[obp++]=(char)0x8D;1014 *((long *)(OpBuffer+obp))=offset;1015 AddLocalVarAddrSchedule();1016 obp+=sizeof(long);1017 }1018 1019 //mov dword ptr[ecx],eax1020 OpBuffer[obp++]=(char)0x89;1021 OpBuffer[obp++]=(char)0x01;1022 }1023 else if(VarKind==VAR_DIRECTMEM){1024 //mov dword ptr[ecx],eax1025 OpBuffer[obp++]=(char)0x89;1026 OpBuffer[obp++]=(char)0x01;1027 }1028 }1029 void SetLongVariable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset){1030 if(type==DEF_DOUBLE||type==DEF_SINGLE){1031 if(type==DEF_DOUBLE){1032 //fld qword ptr[esp]1033 op_fld_ptr_esp(DEF_DOUBLE);1034 1035 //add esp,81036 op_add_esp(8);1037 }1038 else if(type==DEF_SINGLE){1039 //fld dword ptr[esp]1040 op_fld_ptr_esp(DEF_SINGLE);1041 1042 //add esp,41043 op_add_esp(4);1044 }1045 1046 if(VarKind==VAR_GLOBAL){1047 if(bOffsetOffset){1048 //fistp dword ptr[ecx+offset]1049 fpu_cast();1050 OpBuffer[obp++]=(char)0xDB;1051 OpBuffer[obp++]=(char)0x99;1052 *((long *)(OpBuffer+obp))=offset;1053 pobj_GlobalVarSchedule->add();1054 obp+=sizeof(long);1055 fpu_cast_end();1056 }1057 else{1058 //fistp dword ptr[offset]1059 fpu_cast();1060 OpBuffer[obp++]=(char)0xDB;1061 OpBuffer[obp++]=(char)0x1D;1062 *((long *)(OpBuffer+obp))=offset;1063 pobj_GlobalVarSchedule->add();1064 obp+=sizeof(long);1065 fpu_cast_end();1066 }1067 }1068 else if(VarKind==VAR_REFGLOBAL){1069 //mov eax,dword ptr[offset]1070 op_mov_RM( sizeof(long), REG_EAX, REG_NON, (int)offset, MOD_DISP32 );1071 obp-=sizeof(long);1072 pobj_GlobalVarSchedule->add();1073 obp+=sizeof(long);1074 1075 if(bOffsetOffset){1076 //add eax,ecx1077 OpBuffer[obp++]=(char)0x03;1078 OpBuffer[obp++]=(char)0xC1;1079 }1080 1081 //fistp dword ptr[eax]1082 fpu_cast();1083 OpBuffer[obp++]=(char)0xDB;1084 OpBuffer[obp++]=(char)0x18;1085 fpu_cast_end();1086 }1087 else if(VarKind==VAR_LOCAL){1088 if(bOffsetOffset){1089 //add ecx,offset1090 OpBuffer[obp++]=(char)0x81;1091 OpBuffer[obp++]=(char)0xC1;1092 *((long *)(OpBuffer+obp))=offset;1093 AddLocalVarAddrSchedule();1094 obp+=sizeof(long);1095 1096 //fistp dword ptr[ebp+ecx]1097 fpu_cast();1098 OpBuffer[obp++]=(char)0xDB;1099 OpBuffer[obp++]=(char)0x5C;1100 OpBuffer[obp++]=(char)0x0D;1101 OpBuffer[obp++]=(char)0x00;1102 fpu_cast_end();1103 }1104 else{1105 //fistp dword ptr[ebp+offset]1106 fpu_cast();1107 OpBuffer[obp++]=(char)0xDB;1108 OpBuffer[obp++]=(char)0x9D;1109 *((long *)(OpBuffer+obp))=offset;1110 AddLocalVarAddrSchedule();1111 obp+=sizeof(long);1112 fpu_cast_end();1113 }1114 }1115 else if(VarKind==VAR_REFLOCAL){1116 //mov eax,dword ptr[ebp+offset]1117 OpBuffer[obp++]=(char)0x8B;1118 OpBuffer[obp++]=(char)0x85;1119 *((long *)(OpBuffer+obp))=offset;1120 AddLocalVarAddrSchedule();1121 obp+=sizeof(long);1122 1123 if(bOffsetOffset){1124 //add eax,ecx1125 OpBuffer[obp++]=(char)0x03;1126 OpBuffer[obp++]=(char)0xC1;1127 }1128 1129 //fistp dword ptr[eax]1130 fpu_cast();1131 OpBuffer[obp++]=(char)0xDB;1132 OpBuffer[obp++]=(char)0x18;1133 fpu_cast_end();1134 }1135 else if(VarKind==VAR_DIRECTMEM){1136 //fistp dword ptr[ecx]1137 fpu_cast();1138 OpBuffer[obp++]=(char)0xDB;1139 OpBuffer[obp++]=(char)0x19;1140 fpu_cast_end();1141 }1142 }1143 else{1144 //実数以外の型からの代入処理はDWordのものと同様1145 SetDWordVariable(type,VarKind,offset,bOffsetOffset);1146 }1147 }1148 void Set16Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset){1149 ChangeTypeToWhole(type,DEF_INTEGER);1150 1151 //pop eax1152 op_pop(REG_EAX);1153 1154 if(VarKind==VAR_GLOBAL){1155 if(bOffsetOffset){1156 //mov word ptr[ecx+offset],ax1157 OpBuffer[obp++]=(char)0x66;1158 OpBuffer[obp++]=(char)0x89;1159 OpBuffer[obp++]=(char)0x81;1160 *((long *)(OpBuffer+obp))=offset;1161 pobj_GlobalVarSchedule->add();1162 obp+=sizeof(long);1163 }1164 else{1165 //mov word ptr[offset],ax1166 OpBuffer[obp++]=(char)0x66;1167 OpBuffer[obp++]=(char)0xA3;1168 *((long *)(OpBuffer+obp))=offset;1169 pobj_GlobalVarSchedule->add();1170 obp+=sizeof(long);1171 }1172 }1173 else if(VarKind==VAR_REFGLOBAL){1174 //mov ebx,dword ptr[offset]1175 op_mov_RM( sizeof(long), REG_EBX, REG_NON, (int)offset, MOD_DISP32 );1176 obp-=sizeof(long);1177 pobj_GlobalVarSchedule->add();1178 obp+=sizeof(long);1179 1180 if(bOffsetOffset){1181 //add ebx,ecx1182 OpBuffer[obp++]=(char)0x03;1183 OpBuffer[obp++]=(char)0xD9;1184 }1185 1186 //mov word ptr[ebx],ax1187 OpBuffer[obp++]=(char)0x66;1188 OpBuffer[obp++]=(char)0x89;1189 OpBuffer[obp++]=(char)0x03;1190 }1191 else if(VarKind==VAR_LOCAL){1192 if(bOffsetOffset){1193 //add ecx,offset1194 OpBuffer[obp++]=(char)0x81;1195 OpBuffer[obp++]=(char)0xC1;1196 *((long *)(OpBuffer+obp))=offset;1197 AddLocalVarAddrSchedule();1198 obp+=sizeof(long);1199 1200 //mov word ptr[ebp+ecx],ax1201 OpBuffer[obp++]=(char)0x66;1202 OpBuffer[obp++]=(char)0x89;1203 OpBuffer[obp++]=(char)0x44;1204 OpBuffer[obp++]=(char)0x0D;1205 OpBuffer[obp++]=(char)0x00;1206 }1207 else{1208 //mov word ptr[ebp+offset],ax1209 OpBuffer[obp++]=(char)0x66;1210 OpBuffer[obp++]=(char)0x89;1211 OpBuffer[obp++]=(char)0x85;1212 *((long *)(OpBuffer+obp))=offset;1213 AddLocalVarAddrSchedule();1214 obp+=sizeof(long);1215 }1216 }1217 else if(VarKind==VAR_REFLOCAL){1218 //mov ebx,dword ptr[ebp+offset]1219 OpBuffer[obp++]=(char)0x8B;1220 OpBuffer[obp++]=(char)0x9D;1221 *((long *)(OpBuffer+obp))=offset;1222 AddLocalVarAddrSchedule();1223 obp+=sizeof(long);1224 1225 if(bOffsetOffset){1226 //add ebx,ecx1227 OpBuffer[obp++]=(char)0x03;1228 OpBuffer[obp++]=(char)0xD9;1229 }1230 1231 //mov word ptr[ebx],ax1232 OpBuffer[obp++]=(char)0x66;1233 OpBuffer[obp++]=(char)0x89;1234 OpBuffer[obp++]=(char)0x03;1235 }1236 else if(VarKind==VAR_DIRECTMEM){1237 //mov word ptr[ecx],ax1238 OpBuffer[obp++]=(char)0x66;1239 OpBuffer[obp++]=(char)0x89;1240 OpBuffer[obp++]=(char)0x01;1241 }1242 }1243 void Set8Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset){1244 ChangeTypeToWhole(type,DEF_SBYTE);1245 1246 //pop eax1247 op_pop(REG_EAX);1248 1249 if(VarKind==VAR_GLOBAL){1250 if(bOffsetOffset){1251 //mov byte ptr[ecx+offset],al1252 OpBuffer[obp++]=(char)0x88;1253 OpBuffer[obp++]=(char)0x81;1254 *((long *)(OpBuffer+obp))=offset;1255 pobj_GlobalVarSchedule->add();1256 obp+=sizeof(long);1257 }1258 else{1259 //mov byte ptr[offset],al1260 OpBuffer[obp++]=(char)0xA2;1261 *((long *)(OpBuffer+obp))=offset;1262 pobj_GlobalVarSchedule->add();1263 obp+=sizeof(long);1264 }1265 }1266 else if(VarKind==VAR_REFGLOBAL){1267 //mov ebx,dword ptr[offset]1268 op_mov_RM( sizeof(long), REG_EBX, REG_NON, (int)offset, MOD_DISP32 );1269 obp-=sizeof(long);1270 pobj_GlobalVarSchedule->add();1271 obp+=sizeof(long);1272 1273 if(bOffsetOffset){1274 //add ebx,ecx1275 OpBuffer[obp++]=(char)0x03;1276 OpBuffer[obp++]=(char)0xD9;1277 }1278 1279 //mov byte ptr[ebx],al1280 OpBuffer[obp++]=(char)0x88;1281 OpBuffer[obp++]=(char)0x03;1282 }1283 else if(VarKind==VAR_LOCAL){1284 if(bOffsetOffset){1285 //add ecx,offset1286 OpBuffer[obp++]=(char)0x81;1287 OpBuffer[obp++]=(char)0xC1;1288 *((long *)(OpBuffer+obp))=offset;1289 AddLocalVarAddrSchedule();1290 obp+=sizeof(long);1291 1292 //mov byte ptr[ebp+ecx],al1293 OpBuffer[obp++]=(char)0x88;1294 OpBuffer[obp++]=(char)0x44;1295 OpBuffer[obp++]=(char)0x0D;1296 OpBuffer[obp++]=(char)0x00;1297 }1298 else{1299 //mov byte ptr[ebp+offset],al1300 OpBuffer[obp++]=(char)0x88;1301 OpBuffer[obp++]=(char)0x85;1302 *((long *)(OpBuffer+obp))=offset;1303 AddLocalVarAddrSchedule();1304 obp+=sizeof(long);1305 }1306 }1307 else if(VarKind==VAR_REFLOCAL){1308 //mov ebx,dword ptr[ebp+offset]1309 OpBuffer[obp++]=(char)0x8B;1310 OpBuffer[obp++]=(char)0x9D;1311 *((long *)(OpBuffer+obp))=offset;1312 AddLocalVarAddrSchedule();1313 obp+=sizeof(long);1314 1315 if(bOffsetOffset){1316 //add ebx,ecx1317 OpBuffer[obp++]=(char)0x03;1318 OpBuffer[obp++]=(char)0xD9;1319 }1320 1321 //mov byte ptr[ebx],al1322 OpBuffer[obp++]=(char)0x88;1323 OpBuffer[obp++]=(char)0x03;1324 }1325 else if(VarKind==VAR_DIRECTMEM){1326 //mov byte ptr[ecx],al1327 OpBuffer[obp++]=(char)0x88;1328 OpBuffer[obp++]=(char)0x01;1329 }1330 }1331 */ -
BasicCompiler32/Compile_Var.cpp
r95 r96 1218 1218 SetVariableFromEax( DEF_OBJECT, DEF_OBJECT, &RelativeVar ); 1219 1219 } 1220 1221 /*1222 TODO: 消す1223 変数は抽象クラスでもOK1224 if( type.IsObject() ){1225 if( type.GetClass().IsAbstract() ){1226 //抽象クラスだったとき1227 SetError(125,type.GetClass().name,cp);1228 }1229 }1230 */1231 1220 } 1232 1221
Note:
See TracChangeset
for help on using the changeset viewer.