Changeset 308 in dev for trunk/abdev
- Timestamp:
- Aug 29, 2007, 9:05:22 AM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/Compile_Calc_PushVar.cpp
r290 r308 59 59 } 60 60 } 61 void SetReg_WholeVariable( Type &type, RELATIVE_VAR *pRelativeVar,int reg, bool is64Head)61 void SetReg_WholeVariable( const Type &type, RELATIVE_VAR *pRelativeVar,int reg, bool is64Head) 62 62 { 63 63 int varSize; -
trunk/abdev/BasicCompiler32/Compile_ProcOp.cpp
r299 r308 226 226 Compile_AddGlobalRootsForGc(); 227 227 } 228 else if( userProc.GetName() == compiler.globalAreaProcName ){ 229 //////////////////////////////////////// 230 // グローバル領域をコンパイル 231 //////////////////////////////////////// 232 233 const UserProc *pBackUserProc = &UserProc::CompilingUserProc(); 234 UserProc::CompileStartForGlobalArea(); 235 236 int BackCp = cp; 237 cp=-1; 238 239 //クラスに属する静的メンバを定義 240 compiler.GetObjectModule().meta.GetClasses().InitStaticMember(); 241 242 //グローバル実行領域をコンパイル開始 243 CompileBuffer(0,0); 244 245 //Goto未知ラベルスケジュールが存在したらエラーにする 246 BOOST_FOREACH( const GotoLabelSchedule *pGotoLabelSchedule, compiler.codeGenerator.gotoLabelSchedules ) 247 { 248 if(pGotoLabelSchedule->GetName().size()>0){ 249 SetError(6,pGotoLabelSchedule->GetName(),pGotoLabelSchedule->GetSourceCodePos()); 250 } 251 else{ 252 char temporary[255]; 253 sprintf(temporary,"%d",pGotoLabelSchedule->GetLineNum()); 254 SetError(6,temporary,pGotoLabelSchedule->GetSourceCodePos()); 255 } 256 } 257 258 UserProc::CompileStartForUserProc( pBackUserProc ); 259 cp=BackCp; 260 } 228 261 else{ 229 262 SetError(); … … 422 455 //Continueアドレスを初期化 423 456 compiler.codeGenerator.ClearContinueArea(); 457 458 //レキシカルスコープ情報を初期化 459 compiler.codeGenerator.lexicalScopes.Init( compiler.codeGenerator.GetNativeCodeSize() ); 424 460 425 461 const PertialSchedule *pEspOffsetPertialSchedule = NULL; … … 768 804 } 769 805 void CompileLocal(){ 770 if( compiler.IsDll() ){ 806 if( compiler.IsDll() ) 807 { 771 808 //DLLの場合はグローバル変数を初期化するための関数を一番初めにコンパイルする 772 809 const UserProc *pUserProc=GetSubHash("_System_InitDllGlobalVariables"); … … 775 812 } 776 813 else SetError(300,NULL,cp); 814 } 815 else 816 { 817 // グローバル領域を一番初めにコンパイルする 818 extern const UserProc *pSub_System_GlobalArea; 819 CompileBufferInProcedure( *pSub_System_GlobalArea ); 777 820 } 778 821 -
trunk/abdev/BasicCompiler32/MakePeHdr.cpp
r294 r308 7 7 #include <jenga/include/smoothie/Smoothie.h> 8 8 9 #include <LexicalScope.h>10 9 #include <Class.h> 11 10 #include <Compiler.h> 12 #include <NamespaceSupporter.h>13 11 14 12 #include <../Enum.h> … … 18 16 #include "Opcode.h" 19 17 20 extern int GlobalOpBufferSize;21 22 18 23 19 //////////////////////////// … … 28 24 const UserProc 29 25 *pSub_System_StartupProgram, 26 *pSub_System_GlobalArea, 30 27 *pSub_DebugSys_StartProc, 31 28 *pSub_DebugSys_EndProc, … … 106 103 107 104 108 void DebugVariable(void){109 char temporary[255];110 if( compiler.GetObjectModule().meta.GetGlobalVars().Find( Symbol( "_DebugSys_dwThreadID" ) ) == NULL )111 {112 // 未定義の場合は定義する113 sprintf(temporary,"_DebugSys_dwThreadID[255]%c%cDWord",1,ESC_AS);114 OpcodeDim(temporary,DIMFLAG_INITDEBUGVAR);115 sprintf(temporary,"_DebugSys_ProcNum[255]%c%cDWord",1,ESC_AS);116 OpcodeDim(temporary,DIMFLAG_INITDEBUGVAR);117 sprintf(temporary,"_DebugSys_lplpObp[255]%c%c*ULONG_PTR",1,ESC_AS);118 OpcodeDim(temporary,DIMFLAG_INITDEBUGVAR);119 sprintf(temporary,"_DebugSys_lplpSpBase[255]%c%c*ULONG_PTR",1,ESC_AS);120 OpcodeDim(temporary,DIMFLAG_INITDEBUGVAR);121 }122 }123 124 105 void Compile(void){ 125 106 extern HWND hMainDlg; … … 220 201 pSub_System_StartupProgram->Using(); 221 202 203 if(pSub_System_GlobalArea=GetSubHash(compiler.globalAreaProcName.c_str(),1)) 204 { 205 pSub_System_GlobalArea->Using(); 206 pSub_System_GlobalArea->ThisIsAutoGenerationProc(); 207 } 208 222 209 if(pSub_DebugSys_StartProc=GetSubHash("_DebugSys_StartProc",1)) 223 210 pSub_DebugSys_StartProc->Using(); … … 392 379 if(bDebugCompile) 393 380 { 394 // デバッグ用の変数を定義381 // デバッグ用の変数を定義 395 382 DebugVariable(); 396 383 } 397 384 398 // GC用の変数を定義385 // GC用の変数を定義 399 386 InitGCVariables(); 400 387 401 // _System_StartupProgramの呼び出し388 // _System_StartupProgram の呼び出し 402 389 compiler.codeGenerator.op_call(pSub_System_StartupProgram); 403 390 } 404 391 405 //クラスに属する静的メンバを定義 406 compiler.GetObjectModule().meta.GetClasses().InitStaticMember(); 407 408 //グローバル実行領域をコンパイル開始 409 CompileBuffer(0,0); 410 411 //Goto未知ラベルスケジュールが存在したらエラーにする 412 BOOST_FOREACH( const GotoLabelSchedule *pGotoLabelSchedule, compiler.codeGenerator.gotoLabelSchedules ) 413 { 414 if(pGotoLabelSchedule->GetName().size()>0){ 415 SetError(6,pGotoLabelSchedule->GetName(),pGotoLabelSchedule->GetSourceCodePos()); 416 } 417 else{ 418 sprintf(temporary,"%d",pGotoLabelSchedule->GetLineNum()); 419 SetError(6,temporary,pGotoLabelSchedule->GetSourceCodePos()); 420 } 421 } 422 392 // _System_GlobalArea の呼び出し 393 compiler.codeGenerator.op_call( pSub_System_GlobalArea ); 423 394 424 395 if( !compiler.IsStaticLibrary() ) … … 444 415 445 416 //グローバル実行領域のコードサイズ 417 extern int GlobalOpBufferSize; 446 418 GlobalOpBufferSize = compiler.linker.GetNativeCode().GetSize(); 447 419 -
trunk/abdev/BasicCompiler32/NumOpe_Logical.cpp
r290 r308 450 450 451 451 //cmp eax,0 452 compiler.codeGenerator.op_cmp_value(Type(type[sp-1] ,-1).GetSize(),REG_EAX,0);452 compiler.codeGenerator.op_cmp_value(Type(type[sp-1]).GetSize(),REG_EAX,0); 453 453 454 454 //setne al -
trunk/abdev/BasicCompiler32/Opcode.h
r301 r308 147 147 //Compile_Calc_PushVar.cpp 148 148 void SetReg_RealVariable(int type,RELATIVE_VAR *pRelativeVar); 149 void SetReg_WholeVariable( Type &type, RELATIVE_VAR *pRelativeVar,int reg, bool is64Head = false);149 void SetReg_WholeVariable( const Type &type, RELATIVE_VAR *pRelativeVar,int reg, bool is64Head = false); 150 150 void PushLongVariable(RELATIVE_VAR *pRelativeVar); 151 151 -
trunk/abdev/BasicCompiler64/BasicCompiler.vcproj
r270 r308 82 82 Name="VCLinkerTool" 83 83 AdditionalOptions="/MACHINE:AMD64" 84 AdditionalDependencies="comctl32.lib psapi.lib bufferoverflowu.lib commond.lib smoothied.lib "84 AdditionalDependencies="comctl32.lib psapi.lib bufferoverflowu.lib commond.lib smoothied.lib imagehlp.lib" 85 85 OutputFile="../ActiveBasic/BasicCompiler64.exe" 86 86 LinkIncremental="2" … … 194 194 Name="VCLinkerTool" 195 195 AdditionalOptions="/MACHINE:AMD64" 196 AdditionalDependencies="comctl32.lib psapi.lib bufferoverflowu.lib common.lib smoothie.lib "196 AdditionalDependencies="comctl32.lib psapi.lib bufferoverflowu.lib common.lib smoothie.lib imagehlp.lib" 197 197 OutputFile="../ActiveBasic/BasicCompiler64.exe" 198 198 LinkIncremental="1" … … 412 412 </File> 413 413 </Filter> 414 <Filter 415 Name="Low Level Classes" 416 > 417 <File 418 RelativePath="..\BasicCompiler_Common\include\StackFrame.h" 419 > 420 </File> 421 </Filter> 414 422 </Filter> 415 423 </Filter> … … 502 510 <Tool 503 511 Name="VCCLCompilerTool" 504 UsePrecompiledHeader=" 0"512 UsePrecompiledHeader="2" 505 513 BrowseInformation="0" 506 514 /> … … 511 519 <Tool 512 520 Name="VCCLCompilerTool" 513 UsePrecompiledHeader=" 0"521 UsePrecompiledHeader="2" 514 522 BrowseInformation="0" 515 523 /> … … 524 532 <Tool 525 533 Name="VCCLCompilerTool" 526 UsePrecompiledHeader=" 0"534 UsePrecompiledHeader="2" 527 535 BrowseInformation="0" 528 536 /> … … 533 541 <Tool 534 542 Name="VCCLCompilerTool" 535 UsePrecompiledHeader=" 0"543 UsePrecompiledHeader="2" 536 544 BrowseInformation="0" 537 545 /> … … 546 554 <Tool 547 555 Name="VCCLCompilerTool" 548 UsePrecompiledHeader=" 0"556 UsePrecompiledHeader="2" 549 557 BrowseInformation="0" 550 558 /> … … 555 563 <Tool 556 564 Name="VCCLCompilerTool" 557 UsePrecompiledHeader=" 0"565 UsePrecompiledHeader="2" 558 566 BrowseInformation="0" 559 567 /> … … 568 576 <Tool 569 577 Name="VCCLCompilerTool" 570 UsePrecompiledHeader=" 0"578 UsePrecompiledHeader="2" 571 579 BrowseInformation="0" 572 580 /> … … 577 585 <Tool 578 586 Name="VCCLCompilerTool" 579 UsePrecompiledHeader=" 0"587 UsePrecompiledHeader="2" 580 588 BrowseInformation="0" 581 589 /> … … 593 601 <Tool 594 602 Name="VCCLCompilerTool" 595 UsePrecompiledHeader=" 0"596 BrowseInformation="0" 597 /> 598 </FileConfiguration> 599 <FileConfiguration 600 Name="Release|Win32" 601 > 602 <Tool 603 Name="VCCLCompilerTool" 604 UsePrecompiledHeader=" 0"603 UsePrecompiledHeader="2" 604 BrowseInformation="0" 605 /> 606 </FileConfiguration> 607 <FileConfiguration 608 Name="Release|Win32" 609 > 610 <Tool 611 Name="VCCLCompilerTool" 612 UsePrecompiledHeader="2" 605 613 BrowseInformation="0" 606 614 /> … … 615 623 <Tool 616 624 Name="VCCLCompilerTool" 617 UsePrecompiledHeader=" 0"618 BrowseInformation="0" 619 /> 620 </FileConfiguration> 621 <FileConfiguration 622 Name="Release|Win32" 623 > 624 <Tool 625 Name="VCCLCompilerTool" 626 UsePrecompiledHeader=" 0"625 UsePrecompiledHeader="2" 626 BrowseInformation="0" 627 /> 628 </FileConfiguration> 629 <FileConfiguration 630 Name="Release|Win32" 631 > 632 <Tool 633 Name="VCCLCompilerTool" 634 UsePrecompiledHeader="2" 627 635 BrowseInformation="0" 628 636 /> … … 637 645 <Tool 638 646 Name="VCCLCompilerTool" 639 UsePrecompiledHeader=" 0"640 BrowseInformation="0" 641 /> 642 </FileConfiguration> 643 <FileConfiguration 644 Name="Release|Win32" 645 > 646 <Tool 647 Name="VCCLCompilerTool" 648 UsePrecompiledHeader=" 0"647 UsePrecompiledHeader="2" 648 BrowseInformation="0" 649 /> 650 </FileConfiguration> 651 <FileConfiguration 652 Name="Release|Win32" 653 > 654 <Tool 655 Name="VCCLCompilerTool" 656 UsePrecompiledHeader="2" 649 657 BrowseInformation="0" 650 658 /> … … 654 662 RelativePath=".\increment.cpp" 655 663 > 664 <FileConfiguration 665 Name="Debug|Win32" 666 > 667 <Tool 668 Name="VCCLCompilerTool" 669 UsePrecompiledHeader="2" 670 /> 671 </FileConfiguration> 672 <FileConfiguration 673 Name="Release|Win32" 674 > 675 <Tool 676 Name="VCCLCompilerTool" 677 UsePrecompiledHeader="2" 678 /> 679 </FileConfiguration> 656 680 </File> 657 681 <File … … 663 687 <Tool 664 688 Name="VCCLCompilerTool" 665 UsePrecompiledHeader=" 0"666 BrowseInformation="0" 667 /> 668 </FileConfiguration> 669 <FileConfiguration 670 Name="Release|Win32" 671 > 672 <Tool 673 Name="VCCLCompilerTool" 674 UsePrecompiledHeader=" 0"689 UsePrecompiledHeader="2" 690 BrowseInformation="0" 691 /> 692 </FileConfiguration> 693 <FileConfiguration 694 Name="Release|Win32" 695 > 696 <Tool 697 Name="VCCLCompilerTool" 698 UsePrecompiledHeader="2" 675 699 BrowseInformation="0" 676 700 /> … … 685 709 <Tool 686 710 Name="VCCLCompilerTool" 687 UsePrecompiledHeader=" 0"688 BrowseInformation="0" 689 /> 690 </FileConfiguration> 691 <FileConfiguration 692 Name="Release|Win32" 693 > 694 <Tool 695 Name="VCCLCompilerTool" 696 UsePrecompiledHeader=" 0"711 UsePrecompiledHeader="2" 712 BrowseInformation="0" 713 /> 714 </FileConfiguration> 715 <FileConfiguration 716 Name="Release|Win32" 717 > 718 <Tool 719 Name="VCCLCompilerTool" 720 UsePrecompiledHeader="2" 697 721 BrowseInformation="0" 698 722 /> … … 707 731 <Tool 708 732 Name="VCCLCompilerTool" 709 UsePrecompiledHeader=" 0"710 BrowseInformation="0" 711 /> 712 </FileConfiguration> 713 <FileConfiguration 714 Name="Release|Win32" 715 > 716 <Tool 717 Name="VCCLCompilerTool" 718 UsePrecompiledHeader=" 0"733 UsePrecompiledHeader="2" 734 BrowseInformation="0" 735 /> 736 </FileConfiguration> 737 <FileConfiguration 738 Name="Release|Win32" 739 > 740 <Tool 741 Name="VCCLCompilerTool" 742 UsePrecompiledHeader="2" 719 743 BrowseInformation="0" 720 744 /> … … 729 753 <Tool 730 754 Name="VCCLCompilerTool" 731 UsePrecompiledHeader=" 0"732 BrowseInformation="0" 733 /> 734 </FileConfiguration> 735 <FileConfiguration 736 Name="Release|Win32" 737 > 738 <Tool 739 Name="VCCLCompilerTool" 740 UsePrecompiledHeader=" 0"755 UsePrecompiledHeader="2" 756 BrowseInformation="0" 757 /> 758 </FileConfiguration> 759 <FileConfiguration 760 Name="Release|Win32" 761 > 762 <Tool 763 Name="VCCLCompilerTool" 764 UsePrecompiledHeader="2" 741 765 BrowseInformation="0" 742 766 /> … … 751 775 <Tool 752 776 Name="VCCLCompilerTool" 753 UsePrecompiledHeader=" 0"754 BrowseInformation="0" 755 /> 756 </FileConfiguration> 757 <FileConfiguration 758 Name="Release|Win32" 759 > 760 <Tool 761 Name="VCCLCompilerTool" 762 UsePrecompiledHeader=" 0"777 UsePrecompiledHeader="2" 778 BrowseInformation="0" 779 /> 780 </FileConfiguration> 781 <FileConfiguration 782 Name="Release|Win32" 783 > 784 <Tool 785 Name="VCCLCompilerTool" 786 UsePrecompiledHeader="2" 763 787 BrowseInformation="0" 764 788 /> … … 772 796 RelativePath=".\Compile_Interface.cpp" 773 797 > 798 <FileConfiguration 799 Name="Debug|Win32" 800 > 801 <Tool 802 Name="VCCLCompilerTool" 803 UsePrecompiledHeader="2" 804 /> 805 </FileConfiguration> 806 <FileConfiguration 807 Name="Release|Win32" 808 > 809 <Tool 810 Name="VCCLCompilerTool" 811 UsePrecompiledHeader="2" 812 /> 813 </FileConfiguration> 774 814 </File> 775 815 <File 776 816 RelativePath=".\Compile_Object.cpp" 777 817 > 818 <FileConfiguration 819 Name="Debug|Win32" 820 > 821 <Tool 822 Name="VCCLCompilerTool" 823 UsePrecompiledHeader="2" 824 /> 825 </FileConfiguration> 826 <FileConfiguration 827 Name="Release|Win32" 828 > 829 <Tool 830 Name="VCCLCompilerTool" 831 UsePrecompiledHeader="2" 832 /> 833 </FileConfiguration> 778 834 </File> 779 835 </Filter> … … 789 845 <Tool 790 846 Name="VCCLCompilerTool" 791 UsePrecompiledHeader=" 0"792 BrowseInformation="0" 793 /> 794 </FileConfiguration> 795 <FileConfiguration 796 Name="Release|Win32" 797 > 798 <Tool 799 Name="VCCLCompilerTool" 800 UsePrecompiledHeader=" 0"847 UsePrecompiledHeader="2" 848 BrowseInformation="0" 849 /> 850 </FileConfiguration> 851 <FileConfiguration 852 Name="Release|Win32" 853 > 854 <Tool 855 Name="VCCLCompilerTool" 856 UsePrecompiledHeader="2" 801 857 BrowseInformation="0" 802 858 /> … … 811 867 <Tool 812 868 Name="VCCLCompilerTool" 869 UsePrecompiledHeader="2" 813 870 ObjectFile="$(IntDir)\$(InputName)1.obj" 814 871 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" … … 820 877 <Tool 821 878 Name="VCCLCompilerTool" 879 UsePrecompiledHeader="2" 822 880 ObjectFile="$(IntDir)\$(InputName)1.obj" 823 881 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" … … 828 886 RelativePath=".\stack_frame.cpp" 829 887 > 888 <FileConfiguration 889 Name="Debug|Win32" 890 > 891 <Tool 892 Name="VCCLCompilerTool" 893 UsePrecompiledHeader="2" 894 /> 895 </FileConfiguration> 896 <FileConfiguration 897 Name="Release|Win32" 898 > 899 <Tool 900 Name="VCCLCompilerTool" 901 UsePrecompiledHeader="2" 902 /> 903 </FileConfiguration> 830 904 </File> 831 905 </Filter> … … 836 910 RelativePath=".\CLockParameter.cpp" 837 911 > 912 <FileConfiguration 913 Name="Debug|Win32" 914 > 915 <Tool 916 Name="VCCLCompilerTool" 917 UsePrecompiledHeader="2" 918 /> 919 </FileConfiguration> 920 <FileConfiguration 921 Name="Release|Win32" 922 > 923 <Tool 924 Name="VCCLCompilerTool" 925 UsePrecompiledHeader="2" 926 /> 927 </FileConfiguration> 838 928 </File> 839 929 <File 840 930 RelativePath=".\Compile_CallProc.cpp" 841 931 > 932 <FileConfiguration 933 Name="Debug|Win32" 934 > 935 <Tool 936 Name="VCCLCompilerTool" 937 UsePrecompiledHeader="2" 938 /> 939 </FileConfiguration> 940 <FileConfiguration 941 Name="Release|Win32" 942 > 943 <Tool 944 Name="VCCLCompilerTool" 945 UsePrecompiledHeader="2" 946 /> 947 </FileConfiguration> 842 948 </File> 843 949 <File … … 849 955 <Tool 850 956 Name="VCCLCompilerTool" 851 UsePrecompiledHeader=" 0"852 BrowseInformation="0" 853 /> 854 </FileConfiguration> 855 <FileConfiguration 856 Name="Release|Win32" 857 > 858 <Tool 859 Name="VCCLCompilerTool" 860 UsePrecompiledHeader=" 0"957 UsePrecompiledHeader="2" 958 BrowseInformation="0" 959 /> 960 </FileConfiguration> 961 <FileConfiguration 962 Name="Release|Win32" 963 > 964 <Tool 965 Name="VCCLCompilerTool" 966 UsePrecompiledHeader="2" 861 967 BrowseInformation="0" 862 968 /> … … 871 977 <Tool 872 978 Name="VCCLCompilerTool" 873 UsePrecompiledHeader=" 0"874 BrowseInformation="0" 875 /> 876 </FileConfiguration> 877 <FileConfiguration 878 Name="Release|Win32" 879 > 880 <Tool 881 Name="VCCLCompilerTool" 882 UsePrecompiledHeader=" 0"979 UsePrecompiledHeader="2" 980 BrowseInformation="0" 981 /> 982 </FileConfiguration> 983 <FileConfiguration 984 Name="Release|Win32" 985 > 986 <Tool 987 Name="VCCLCompilerTool" 988 UsePrecompiledHeader="2" 883 989 BrowseInformation="0" 884 990 /> … … 888 994 RelativePath=".\CParameter.cpp" 889 995 > 996 <FileConfiguration 997 Name="Debug|Win32" 998 > 999 <Tool 1000 Name="VCCLCompilerTool" 1001 UsePrecompiledHeader="2" 1002 /> 1003 </FileConfiguration> 1004 <FileConfiguration 1005 Name="Release|Win32" 1006 > 1007 <Tool 1008 Name="VCCLCompilerTool" 1009 UsePrecompiledHeader="2" 1010 /> 1011 </FileConfiguration> 890 1012 </File> 891 1013 <File 892 1014 RelativePath=".\OperatorProc.cpp" 893 1015 > 1016 <FileConfiguration 1017 Name="Debug|Win32" 1018 > 1019 <Tool 1020 Name="VCCLCompilerTool" 1021 UsePrecompiledHeader="2" 1022 /> 1023 </FileConfiguration> 1024 <FileConfiguration 1025 Name="Release|Win32" 1026 > 1027 <Tool 1028 Name="VCCLCompilerTool" 1029 UsePrecompiledHeader="2" 1030 /> 1031 </FileConfiguration> 894 1032 </File> 895 1033 </Filter> … … 1101 1239 Name="VCCLCompilerTool" 1102 1240 AdditionalOptions="/bigobj" 1241 UsePrecompiledHeader="0" 1103 1242 /> 1104 1243 </FileConfiguration> … … 1109 1248 Name="VCCLCompilerTool" 1110 1249 AdditionalOptions="/bigobj" 1250 UsePrecompiledHeader="0" 1111 1251 /> 1112 1252 </FileConfiguration> 1113 1253 </File> 1114 <Filter1115 Name="Core Classes"1116 >1117 <File1118 RelativePath="..\BasicCompiler_Common\src\CommonCodeGenerator.cpp"1119 >1120 </File>1121 </Filter>1122 1254 </Filter> 1123 1255 <Filter … … 1144 1276 </File> 1145 1277 <File 1278 RelativePath="..\BasicCompiler_Common\src\CommonCodeGenerator.cpp" 1279 > 1280 </File> 1281 <File 1146 1282 RelativePath="..\BasicCompiler_Common\src\Const.cpp" 1147 1283 > … … 1177 1313 <File 1178 1314 RelativePath="..\BasicCompiler_Common\src\NativeCode.cpp" 1315 > 1316 </File> 1317 <File 1318 RelativePath="..\BasicCompiler_Common\src\ObjectModule.cpp" 1179 1319 > 1180 1320 </File> -
trunk/abdev/BasicCompiler64/CParameter.cpp
r226 r308 348 348 else if( dummyType.IsWhole() ){ 349 349 //実数型 → 整数型 350 ChangeTypeToWhole(calcType .GetBasicType(),dummyType.GetBasicType(),reg,temp_reg);350 ChangeTypeToWhole(calcType,dummyType,reg,temp_reg); 351 351 } 352 352 } … … 376 376 if( calcType.IsReal() ){ 377 377 //実数型 → 整数型 378 ChangeTypeToWhole( calcType .GetBasicType(), DEF_QWORD,reg,temp_reg);378 ChangeTypeToWhole( calcType, Type(DEF_QWORD), reg, temp_reg ); 379 379 } 380 380 } -
trunk/abdev/BasicCompiler64/CodeGenerator.cpp
r262 r308 128 128 } 129 129 130 pNativeCode->Put ( disp, scheduleType );130 pNativeCode->PutEx( disp, scheduleType ); 131 131 } 132 132 … … 176 176 177 177 //即値 178 pNativeCode->Put ( i32data, scheduleType );178 pNativeCode->PutEx( i32data, scheduleType ); 179 179 } 180 180 void CodeGenerator::op_mov_RV64(int reg,_int64 i64data){ … … 247 247 pPertialSchedule = pertialSchedules.back(); 248 248 } 249 pNativeCode->Put ( offset, scheduleType );249 pNativeCode->PutEx( offset, scheduleType ); 250 250 } 251 251 else{ … … 320 320 pPertialSchedule = pertialSchedules.back(); 321 321 } 322 pNativeCode->Put ( offset, scheduleType );322 pNativeCode->PutEx( offset, scheduleType ); 323 323 } 324 324 else{ … … 645 645 pPertialSchedule = pertialSchedules.back(); 646 646 } 647 pNativeCode->Put ( offset, scheduleType );647 pNativeCode->PutEx( offset, scheduleType ); 648 648 649 649 return pPertialSchedule; -
trunk/abdev/BasicCompiler64/Compile_Calc.cpp
r266 r308 9 9 #include "Opcode.h" 10 10 11 void SetVariableFromRax( int VarType,int CalcType,RELATIVE_VAR *pRelativeVar){11 void SetVariableFromRax( const Type &varType, int CalcType,RELATIVE_VAR *pRelativeVar){ 12 12 ///////////////////////////////////////////////// 13 13 // raxの内容を変数にコピーするコードを抽出 14 14 ///////////////////////////////////////////////// 15 15 16 if(VarType==DEF_BOOLEAN){ 16 if( varType.IsBoolean() ) 17 { 17 18 //bool 18 19 SetBooleanVariable(CalcType,pRelativeVar); 19 20 } 20 else if( IsRealNumberType( VarType ) ){ 21 else if( varType.IsReal() ) 22 { 21 23 // Double/Single型変数へレジスタの値を代入 22 SetRealVariable(VarType, CalcType, pRelativeVar); 23 } 24 else if( IsWholeNumberType( VarType ) || VarType == DEF_OBJECT ){ 25 int typeSize = GetTypeSize( VarType, -1 ); 26 24 SetRealVariable(varType.GetBasicType(), CalcType, pRelativeVar); 25 } 26 else if( varType.IsWhole() || varType.IsObject() ) 27 { 27 28 //整数変数へraxの値を格納する 28 SetWholeVariable( typeSize, CalcType, pRelativeVar );29 SetWholeVariable( varType.GetSize(), CalcType, pRelativeVar ); 29 30 } 30 31 else{ … … 265 266 // rax(実数はxmm0)の内容を変数にコピー 266 267 ///////////////////////////////////////////////// 267 SetVariableFromRax(varType .GetBasicType(),calcType.GetBasicType(),&VarRelativeVar);268 SetVariableFromRax(varType,calcType.GetBasicType(),&VarRelativeVar); 268 269 } -
trunk/abdev/BasicCompiler64/Compile_Calc_PushVar.cpp
r254 r308 125 125 126 126 127 void SetReg_WholeVariable(int type,RELATIVE_VAR *pRelativeVar,int reg){ 128 int varSize; 129 130 varSize=GetTypeSize(type,-1); 127 void SetReg_WholeVariable( const Type &type, RELATIVE_VAR *pRelativeVar,int reg) 128 { 129 int varSize = type.GetSize(); 131 130 132 131 if(pRelativeVar->dwKind==VAR_GLOBAL){ -
trunk/abdev/BasicCompiler64/Compile_CallProc.cpp
r304 r308 89 89 } 90 90 91 bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName,int RefType){ 92 // TODO: RefTypeは不必要なので削除する 91 bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName){ 93 92 int i2; 94 93 … … 131 130 Type varType; 132 131 GetVarType( ObjectName, varType, false ); 133 pobj_c = &varType.GetClass(); 134 if( NATURAL_TYPE( varType.GetBasicType() ) != DEF_OBJECT ){ 132 if( NATURAL_TYPE( varType.GetBasicType() ) == DEF_OBJECT ) 133 { 134 pobj_c = &varType.GetClass(); 135 leftType = varType; 136 } 137 else 138 { 135 139 pobj_c=compiler.GetObjectModule().meta.GetClasses().Find(ObjectName); 136 140 if( pobj_c ){ -
trunk/abdev/BasicCompiler64/Compile_Func.cpp
r266 r308 108 108 109 109 char ObjectName[VN_SIZE]; 110 int RefType;111 SplitObjectName(name,ObjectName, &RefType);110 ReferenceKind referenceKind; 111 SplitObjectName(name,ObjectName, referenceKind ); 112 112 113 113 if(ObjectName[0]){ … … 120 120 121 121 //参照タイプが整合しているかをチェック 122 if(type.GetBasicType()!=RefType) SetError(104,ObjectName,cp); 122 if( !( type.IsObject() && referenceKind == RefDot 123 || type.IsObjectPtr() && referenceKind == RefPointer ) ) 124 { 125 SetError(104,ObjectName,cp); 126 } 123 127 124 128 if(type.IsObjectPtr()){ … … 166 170 void Opcode_Func_SizeOf( const string &typeName ){ 167 171 Type tempType; 168 if( ! Compiler::StringToType( typeName, tempType ) ){172 if( !compiler.StringToType( typeName, tempType ) ){ 169 173 SetError(3,typeName,cp); 170 174 return; … … 268 272 else{ 269 273 //mov rax,ptr[rax] 270 compiler.codeGenerator.op_mov_RM( GetTypeSize(type,-1),REG_RAX,REG_RAX,0,MOD_BASE);274 compiler.codeGenerator.op_mov_RM(Type(type).GetSize(),REG_RAX,REG_RAX,0,MOD_BASE); 271 275 } 272 276 } -
trunk/abdev/BasicCompiler64/Compile_Object.cpp
r263 r308 51 51 Opcode_CallProc(CreateParameter, 52 52 pUserProc, 53 PROCFLAG_NEW,"" ,0);53 PROCFLAG_NEW,""); 54 54 55 55 { … … 64 64 Opcode_CallProc(temporary, 65 65 subs[0], 66 PROCFLAG_NEW,"" ,0);66 PROCFLAG_NEW,""); 67 67 } 68 68 else{ -
trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp
r266 r308 182 182 else bDebugSupportProc=0; 183 183 184 pUserProc->_beginOpAddressOld = obp;185 186 184 //コンパイル中の関数が属するクラス 187 185 compiler.pCompilingClass=pUserProc->GetParentClassPtr(); … … 211 209 212 210 //スタックフレーム管理用オブジェクトを初期化 213 extern CStackFrame *pobj_sf;214 pobj_sf=new CStackFrame();211 extern StackFrame *pobj_sf; 212 pobj_sf=new StackFrame(); 215 213 216 214 SystemProc(*pUserProc); … … 220 218 pobj_sf=0; 221 219 222 pUserProc->_endOpAddressOld = obp;223 220 return; 224 221 } … … 232 229 //プロシージャ抜け出しスケジュール(Exit Sub/Function) 233 230 compiler.codeGenerator.exitSubCodePositions.clear(); 234 compiler.codeGenerator._exitSubCodePositions_ObpOld.clear();235 231 236 232 //ラベル用のメモリを確保 … … 260 256 261 257 //レキシカルスコープ情報を初期化 262 compiler.codeGenerator.lexicalScopes.Init( obp);258 compiler.codeGenerator.lexicalScopes.Init( compiler.codeGenerator.GetNativeCodeSize() ); 263 259 264 260 … … 271 267 Parameter ¶m = *pUserProc->RealParams()[i3]; 272 268 273 Variable *pVar = new Variable( param.GetVarName(), param, false, param.IsRef(), "" );269 Variable *pVar = new Variable( param.GetVarName(), param, false, param.IsRef(), "", false ); 274 270 275 271 if( param.IsArray() ){ … … 307 303 308 304 //スタックフレーム管理用クラスを初期化 309 extern CStackFrame *pobj_sf;310 pobj_sf=new CStackFrame();305 extern StackFrame *pobj_sf; 306 pobj_sf=new StackFrame(); 311 307 312 308 … … 390 386 else{ 391 387 if( pUserProc->ReturnType().IsObject() ){ 392 sprintf(temporary,"%s=Nothing%c%c%s",temp,1,ESC_AS, Compiler::TypeToString( pUserProc->ReturnType() ).c_str() );388 sprintf(temporary,"%s=Nothing%c%c%s",temp,1,ESC_AS, compiler.TypeToString( pUserProc->ReturnType() ).c_str() ); 393 389 } 394 390 else{ 395 391 //戻り値用の変数の定義 396 sprintf(temporary,"%s%c%c%s",temp,1,ESC_AS, Compiler::TypeToString( pUserProc->ReturnType() ).c_str() );392 sprintf(temporary,"%s%c%c%s",temp,1,ESC_AS, compiler.TypeToString( pUserProc->ReturnType() ).c_str() ); 397 393 } 398 394 … … 477 473 &compiler.pCompilingClass->GetSuperClass().GetConstructorMethod()->GetUserProc(), 478 474 0, 479 "", 480 0); 475 ""); 481 476 } 482 477 } … … 553 548 &method->GetUserProc(), 554 549 0, 555 "", 556 0); 550 ""); 557 551 } 558 552 } … … 612 606 else if(IsWholeNumberType(i3)){ 613 607 //整数型 614 SetReg_WholeVariable( i3,&RelativeVar,REG_RAX);608 SetReg_WholeVariable(Type(i3),&RelativeVar,REG_RAX); 615 609 } 616 610 else SetError(300,NULL,cp); … … 666 660 delete pobj_sf; 667 661 pobj_sf=0; 668 669 670 pUserProc->_endOpAddressOld = obp;671 662 672 663 -
trunk/abdev/BasicCompiler64/Compile_Set_Var.cpp
r254 r308 249 249 250 250 //cmp rax,0 251 compiler.codeGenerator.op_cmp_value( GetTypeSize(type,-1),REG_RAX,0);251 compiler.codeGenerator.op_cmp_value(Type(type).GetSize(),REG_RAX,0); 252 252 253 253 //setne al -
trunk/abdev/BasicCompiler64/Compile_Statement.cpp
r266 r308 80 80 } 81 81 82 Opcode_CallProc("",pUserProc,0,"" ,0);82 Opcode_CallProc("",pUserProc,0,""); 83 83 84 84 return; … … 199 199 200 200 //レキシカルスコープをレベルアップ 201 compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_IF ); 201 compiler.codeGenerator.lexicalScopes.Start( 202 compiler.codeGenerator.GetNativeCodeSize(), 203 LexicalScope::SCOPE_TYPE_IF 204 ); 202 205 203 206 int i2=CompileBuffer(ESC_ENDIF,0); … … 220 223 221 224 //レキシカルスコープをレベルアップ 222 compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_IF ); 225 compiler.codeGenerator.lexicalScopes.Start( 226 compiler.codeGenerator.GetNativeCodeSize(), 227 LexicalScope::SCOPE_TYPE_IF 228 ); 223 229 224 230 CompileBuffer(ESC_ENDIF,0); … … 277 283 { 278 284 //jmp ... 279 extern int obp; 280 compiler.codeGenerator.op_jmp( i-obp, sizeof(long), false, true ); 285 compiler.codeGenerator.op_jmp( 286 i-compiler.codeGenerator.GetNativeCodeSize(), 287 sizeof(long), 288 false, 289 true 290 ); 281 291 } 282 292 } … … 293 303 { 294 304 //jmp ... 295 extern int obp; 296 compiler.codeGenerator.op_jmp( i-obp, sizeof(long), false, true ); 305 compiler.codeGenerator.op_jmp( 306 i-compiler.codeGenerator.GetNativeCodeSize(), 307 sizeof(long), 308 false, 309 true 310 ); 297 311 } 298 312 } … … 313 327 314 328 //レキシカルスコープをレベルアップ 315 compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_WHILE );329 compiler.codeGenerator.lexicalScopes.Start( compiler.codeGenerator.GetNativeCodeSize(), LexicalScope::SCOPE_TYPE_WHILE ); 316 330 317 331 //While内をコンパイル … … 431 445 432 446 //レキシカルスコープをレベルアップ 433 compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_FOR );447 compiler.codeGenerator.lexicalScopes.Start( compiler.codeGenerator.GetNativeCodeSize(), LexicalScope::SCOPE_TYPE_FOR ); 434 448 435 449 //For内をコンパイル … … 467 481 468 482 //レキシカルスコープをレベルアップ 469 compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_DO );483 compiler.codeGenerator.lexicalScopes.Start( compiler.codeGenerator.GetNativeCodeSize(), LexicalScope::SCOPE_TYPE_DO ); 470 484 471 485 //Do内をコンパイル … … 743 757 744 758 //cmp reg2,r14 745 compiler.codeGenerator.op_cmp_reg( GetTypeSize(i2,-1),reg2,REG_R14);759 compiler.codeGenerator.op_cmp_reg(Type(i2).GetSize(),reg2,REG_R14); 746 760 } 747 761 … … 767 781 768 782 //レキシカルスコープをレベルアップ 769 compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_SELECT );783 compiler.codeGenerator.lexicalScopes.Start( compiler.codeGenerator.GetNativeCodeSize(), LexicalScope::SCOPE_TYPE_SELECT ); 770 784 771 785 //Select Case内をコンパイル … … 909 923 } 910 924 else{ 911 ChangeTypeToWhole(resultType .GetBasicType(),type,REG_RCX,temp_reg);925 ChangeTypeToWhole(resultType,Type(type),REG_RCX,temp_reg); 912 926 913 927 //mov ptr[reg_ptr],rcx 914 compiler.codeGenerator.op_mov_MR( GetTypeSize(type,-1),REG_RCX,reg_ptr,0,MOD_BASE);915 } 916 } 928 compiler.codeGenerator.op_mov_MR(Type(type).GetSize(),REG_RCX,reg_ptr,0,MOD_BASE); 929 } 930 } -
trunk/abdev/BasicCompiler64/Compile_Var.cpp
r266 r308 24 24 ///////////////////////////////////////////// 25 25 26 SetReg_WholeVariable( DEF_INT64,pRelativeVar,REG_R11);26 SetReg_WholeVariable(Type(DEF_INT64),pRelativeVar,REG_R11); 27 27 28 28 //mov qword ptr[rsp+offset],r11 ※スタックフレームを利用 … … 376 376 RelativeVar.offset=-LocalVar_ThisPtrOffset; 377 377 378 SetReg_WholeVariable( DEF_PTR_VOID,&RelativeVar,reg);378 SetReg_WholeVariable(Type(DEF_PTR_VOID),&RelativeVar,reg); 379 379 } 380 380 bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType, Subscripts *pResultSubscripts ){ … … 742 742 743 743 bool SetInitGlobalData(int offset,const Type &type,const Subscripts &subscripts,const char *lpszInitBuf){ 744 extern BYTE *initGlobalBuf;745 744 int i2,i3; 746 745 char temporary[VN_SIZE]; … … 846 845 847 846 if( type.IsDouble() ){ 848 *(double *)(initGlobalBuf+offset)=(double)dbl; 847 compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.Overwrite( 848 offset, 849 (const char *)&dbl, 850 sizeof(double) 851 ); 849 852 } 850 853 else if( type.IsSingle() ){ 851 *(float *)(initGlobalBuf+offset)=(float)dbl; 854 float flt = (float)dbl; 855 compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.Overwrite( 856 offset, 857 (const char *)&flt, 858 sizeof(float) 859 ); 852 860 } 853 861 else if( type.Is64() || type.IsPointer() ){ … … 867 875 } 868 876 else{ 869 *(_int64 *)(initGlobalBuf+offset)=i64data; 877 compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.Overwrite( 878 offset, 879 (const char *)&i64data, 880 sizeof(_int64) 881 ); 870 882 } 871 883 } 872 884 else if( type.IsDWord() || type.IsLong() ){ 873 *(DWORD *)(initGlobalBuf+offset)=(DWORD)i64data; 885 long l = (long)i64data; 886 compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.Overwrite( 887 offset, 888 (const char *)&l, 889 sizeof(long) 890 ); 874 891 } 875 892 else if( type.IsWord() || type.IsInteger() ){ 876 *(WORD *)(initGlobalBuf+offset)=(WORD)i64data; 893 short s = (short)i64data; 894 compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.Overwrite( 895 offset, 896 (const char *)&s, 897 sizeof(short) 898 ); 877 899 } 878 900 else if( type.IsSByte() || type.IsByte() || type.IsBoolean() ){ 879 *(BYTE *)(initGlobalBuf+offset)=(BYTE)i64data; 901 char c = (char)i64data; 902 compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.Overwrite( 903 offset, 904 (const char *)&c, 905 sizeof(char) 906 ); 880 907 } 881 908 … … 1057 1084 } 1058 1085 1059 void dim( char *VarName, const Subscripts &subscripts, Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlags){ 1086 void dim( char *VarName, const Subscripts &subscripts, const Type &type,const char *InitBuf,const char *ConstractParameter,DWORD dwFlags) 1087 { 1060 1088 if( UserProc::IsGlobalAreaCompiling() ){ 1061 1089 ///////////////////////// … … 1078 1106 bool isConst = ( dwFlags & DIMFLAG_CONST ) ? true:false; 1079 1107 1080 Variable *pVar = new Variable( VarName, type, isConst, false, ConstractParameter );1108 Variable *pVar = new Variable( VarName, type, isConst, false, ConstractParameter, false ); 1081 1109 1082 1110 if( subscripts.size() > 0 ){ … … 1194 1222 SetError(); 1195 1223 } 1196 SetVariableFromRax( DEF_OBJECT, DEF_OBJECT, &RelativeVar );1224 SetVariableFromRax( Type( DEF_OBJECT, *compiler.GetObjectModule().meta.GetClasses().GetObjectClassPtr() ), DEF_OBJECT, &RelativeVar ); 1197 1225 } 1198 1226 } … … 1296 1324 // call AddGlobalRootPtr 1297 1325 compiler.codeGenerator.op_call( pUserProc_AddGlobalRootPtr ); 1298 1299 ReallocNativeCodeBuffer();1300 1326 } 1301 1327 } -
trunk/abdev/BasicCompiler64/MakePeHdr.cpp
r268 r308 2 2 3 3 #include <jenga/include/common/Environment.h> 4 #include <jenga/include/common/Path.h> 5 #include <jenga/include/common/Directory.h> 4 6 5 7 #include <jenga/include/smoothie/Smoothie.h> … … 29 31 *pSub_System_InitStaticLocalVariables, 30 32 *pSub_System_Call_Destructor_of_GlobalObject, 33 *pSub_System_End, 31 34 *pSub_System_GetSp, 32 35 *pSub_pow, … … 88 91 89 92 90 void DebugVariable(void){91 char temporary[255];92 sprintf(temporary,"_DebugSys_dwThreadID[255]%c%cDWord",1,ESC_AS);93 OpcodeDim(temporary,DIMFLAG_INITDEBUGVAR);94 sprintf(temporary,"_DebugSys_ProcNum[255]%c%cDWord",1,ESC_AS);95 OpcodeDim(temporary,DIMFLAG_INITDEBUGVAR);96 sprintf(temporary,"_DebugSys_lplpObp[255]%c%c*ULONG_PTR",1,ESC_AS);97 OpcodeDim(temporary,DIMFLAG_INITDEBUGVAR);98 sprintf(temporary,"_DebugSys_lplpSpBase[255]%c%c*ULONG_PTR",1,ESC_AS);99 OpcodeDim(temporary,DIMFLAG_INITDEBUGVAR);100 }101 102 93 void Compile(void){ 103 94 extern HWND hMainDlg; … … 158 149 // 名前空間情報を取得 159 150 NamespaceSupporter::CollectNamespaces( 160 compiler. source.GetBuffer(),151 compiler.GetObjectModule().GetCurrentSource().GetBuffer(), 161 152 compiler.GetObjectModule().meta.GetNamespaces() 162 153 ); … … 165 156 // CollectProcedures関数の中で参照されるオブジェクト名を事前に取得する。 166 157 // ※オブジェクトの内容までは取得しない 167 compiler.GetObjectModule().meta.GetClasses().CollectClassesForNameOnly( compiler. source);158 compiler.GetObjectModule().meta.GetClasses().CollectClassesForNameOnly( compiler.GetObjectModule().GetCurrentSource() ); 168 159 169 160 //TypeDef情報を初期化 170 compiler.GetObjectModule().meta.GetTypeDefs(). Init();161 compiler.GetObjectModule().meta.GetTypeDefs().CollectTypeDefs(); 171 162 172 163 //定数情報を取得 … … 176 167 compiler.pCompilingClass = NULL; 177 168 CollectProcedures( 178 compiler. source,169 compiler.GetObjectModule().GetCurrentSource(), 179 170 compiler.GetObjectModule().meta.GetUserProcs(), 180 171 compiler.GetObjectModule().meta.GetDllProcs() … … 262 253 } 263 254 255 if(pSub_System_End=GetSubHash("_System_End",1)){ 256 pSub_System_End->Using(); 257 } 258 264 259 if(pSub_System_GetSp=GetSubHash("_System_GetSp",1)){ 265 260 pSub_System_GetSp->Using(); … … 298 293 } 299 294 300 301 302 //データテーブルスケジュール303 pobj_DataTableSchedule=new CSchedule();304 pobj_DataTableSchedule->SetFlag(SCHEDULE_FLAG_RELOC);305 306 //インポートテーブルスケジュール307 //※x64はRPI(実行中アドレス)からのオフセットになるため、再配置が不要308 pobj_ImportAddrSchedule=new CImportAddrSchedule();309 310 //プロシージャポインタスケジュール311 pobj_SubAddrSchedule=new CSubAddrSchedule();312 313 //グローバル変数アドレススケジュール314 pobj_GlobalVarSchedule=new CSchedule();315 pobj_GlobalVarSchedule->SetFlag(SCHEDULE_FLAG_RELOC);316 317 //グローバル変数の初期バッファ318 extern BYTE *initGlobalBuf;319 initGlobalBuf=(BYTE *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,1);320 321 295 //リロケーション情報 322 296 pobj_Reloc=new CReloc(); 323 297 324 obp_AllocSize=8192*2;325 OpBuffer=(char *)calloc(obp_AllocSize,1);326 obp=0;327 328 298 //レジスタのブロッキングを管理するためのオブジェクトを生成 329 299 pobj_BlockReg=new CBlockReg; 330 300 331 301 //レキシカルスコープ情報を初期化 332 compiler.codeGenerator.lexicalScopes.Init( obp);302 compiler.codeGenerator.lexicalScopes.Init(0); 333 303 334 304 … … 373 343 compiler.codeGenerator.ClearContinueArea(); 374 344 375 //スタックフレーム管理用クラスを初期化 376 extern CStackFrame *pobj_sf; 377 pobj_sf=new CStackFrame(); 345 //スタックフレーム管理用クラスを選択 346 pobj_sf = &compiler.GetObjectModule().globalStackFrame; 378 347 379 348 // コード生成対象を選択 … … 386 355 //breakpoint; 387 356 388 //sub rsp,スタックフレームサイズ 389 const PertialSchedule *pStackFramePertialSchedule = compiler.codeGenerator.op_sub_rsp( 0, true ); 390 391 if(bDebugCompile){ 392 //デバッグ用の変数を定義 393 DebugVariable(); 394 } 395 396 //GC用の変数を定義 397 InitGCVariables(); 398 399 //_System_StartupProgramの呼び出し 400 compiler.codeGenerator.op_call(pSub_System_StartupProgram); 357 if( compiler.IsCore() ) 358 { 359 //sub rsp,スタックフレームサイズ 360 const PertialSchedule *pStackFramePertialSchedule = compiler.codeGenerator.op_sub_rsp( 0, true ); 361 362 if(bDebugCompile){ 363 //デバッグ用の変数を定義 364 DebugVariable(); 365 } 366 367 //GC用の変数を定義 368 InitGCVariables(); 369 370 //_System_StartupProgramの呼び出し 371 compiler.codeGenerator.op_call(pSub_System_StartupProgram); 372 } 401 373 402 374 //クラスに属する静的メンバを定義 … … 419 391 420 392 421 /////////////////////////////////////// 422 // グローバル文字列変数の解放処理 423 /////////////////////////////////////// 424 425 //call _System_Call_Destructor_of_GlobalObject 426 extern const UserProc *pSub_System_Call_Destructor_of_GlobalObject; 427 compiler.codeGenerator.op_call(pSub_System_Call_Destructor_of_GlobalObject); 428 429 430 //add rsp,スタックフレームサイズ 431 int stackFrameSize = pobj_sf->GetFrameSize(0); 432 compiler.codeGenerator.op_add_RV( REG_RSP, stackFrameSize ); 433 434 //xor rax,rax(raxを0に初期化する) 435 compiler.codeGenerator.op_zero_reg(REG_RAX); 436 437 //ret 438 compiler.codeGenerator.op_ret(); 393 if( !compiler.IsStaticLibrary() ) 394 { 395 /////////////////////////////////////// 396 // グローバル文字列変数の解放処理 397 /////////////////////////////////////// 398 399 //call _System_End 400 extern const UserProc *pSub_System_End; 401 compiler.codeGenerator.op_call(pSub_System_End); 402 403 404 //add rsp,スタックフレームサイズ 405 int stackFrameSize = pobj_sf->GetFrameSize(0); 406 compiler.codeGenerator.op_add_RV( REG_RSP, stackFrameSize ); 407 408 //xor rax,rax(raxを0に初期化する) 409 compiler.codeGenerator.op_zero_reg(REG_RAX); 410 411 //ret 412 compiler.codeGenerator.op_ret(); 413 414 //スタックフレームスケジュール(subコマンドに渡す値) 415 compiler.codeGenerator.opfix( pStackFramePertialSchedule, stackFrameSize ); 416 417 //スタックフレームスケジュールを実行 418 pobj_sf->RunningSchedule( stackFrameSize ); 419 pobj_sf=0; 420 } 439 421 440 422 //グローバル実行領域のコードサイズ 441 423 extern int GlobalOpBufferSize; 442 GlobalOpBufferSize=obp; 443 444 //スタックフレームスケジュール(subコマンドに渡す値) 445 compiler.codeGenerator.opfix( pStackFramePertialSchedule, stackFrameSize ); 446 447 //スタックフレームスケジュールを実行 448 pobj_sf->RunningSchedule( stackFrameSize ); 449 delete pobj_sf; 450 pobj_sf=0; 424 GlobalOpBufferSize = compiler.linker.GetNativeCode().GetSize(); 451 425 452 426 //With情報のメモリを解放 … … 504 478 trace( "コード生成が終了しました。" ); 505 479 506 vector<ObjectModule *> masterObjectModules; 507 masterObjectModules.push_back( &compiler.GetObjectModule() ); 508 compiler.linker.Link( masterObjectModules ); 480 481 if( compiler.IsStaticLibrary() ) 482 { 483 // 静的リンクライブラリ 484 485 // 格納先ディレクトリを作る 486 Jenga::Common::Path path( OutputFileName ); 487 Jenga::Common::Directory dir( path.GetDriveName() + path.GetDirName(), true ); 488 489 // 書き込む 490 if( !compiler.GetObjectModule().Write( OutputFileName ) ) 491 { 492 MessageBox(0,"XML書き込みに失敗","test",0); 493 } 494 return; 495 } 496 497 extern BOOL bError; 498 if( !bError ) 499 { 500 CompileMessage( "リンク中..." ); 501 } 502 503 504 compiler.linker.Link( compiler.GetObjectModule() ); 505 506 extern SourceLines oldSourceLines; 507 oldSourceLines = compiler.linker.GetNativeCode().GetSourceLines(); 508 509 510 ///////////////////////////////////////////////////////////////// 511 // vtblの構築 512 ///////////////////////////////////////////////////////////////// 513 514 compiler.GetObjectModule().meta.GetClasses().GenerateVTables(); 515 509 516 510 517 … … 525 532 526 533 if( !pDllProc->IsUsing() ){ 527 pDllProc=pDllProc->pNextData;528 534 continue; 529 535 } … … 619 625 620 626 if( pUserProc->GetName() == "DllMain" ){ 621 DllMain_EntryPoint =pUserProc->_beginOpAddressOld;627 DllMain_EntryPoint = pUserProc->GetBeginOpAddress(); 622 628 } 623 629 624 630 lpdwExportAddressTable=(DWORD *)HeapReAlloc(hHeap,0,lpdwExportAddressTable,(ExportNum+1)*sizeof(DWORD)); 625 lpdwExportAddressTable[ExportNum] =pUserProc->_beginOpAddressOld;631 lpdwExportAddressTable[ExportNum] = pUserProc->GetBeginOpAddress(); 626 632 627 633 lpdwExportNamePointerTable=(DWORD *)HeapReAlloc(hHeap,0,lpdwExportNamePointerTable,(ExportNum+1)*sizeof(DWORD)); … … 703 709 704 710 if( !pDllProc->IsUsing() ){ 705 pDllProc=pDllProc->pNextData;706 711 continue; 707 712 } … … 742 747 743 748 if( !pDllProc->IsUsing() ){ 744 pDllProc=pDllProc->pNextData;745 749 continue; 746 750 } … … 780 784 781 785 if( !pDllProc->IsUsing() ){ 782 pDllProc=pDllProc->pNextData;783 786 continue; 784 787 } … … 855 858 856 859 //コードセッションのファイル上のサイズ 857 if(obp%FILE_ALIGNMENT) FileSize_CodeSection=obp+(FILE_ALIGNMENT-obp%FILE_ALIGNMENT); 858 else FileSize_CodeSection=obp; 860 if(compiler.linker.GetNativeCode().GetSize()%FILE_ALIGNMENT) 861 { 862 FileSize_CodeSection = 863 compiler.linker.GetNativeCode().GetSize() 864 + (FILE_ALIGNMENT-compiler.linker.GetNativeCode().GetSize()%FILE_ALIGNMENT); 865 } 866 else 867 { 868 FileSize_CodeSection = compiler.linker.GetNativeCode().GetSize(); 869 } 859 870 if(FileSize_CodeSection) bUse_CodeSection=1; 860 871 else bUse_CodeSection=0; … … 1052 1063 1053 1064 if( !pDllProc->IsUsing() ){ 1054 pDllProc=pDllProc->pNextData;1055 1065 continue; 1056 1066 } … … 1070 1080 1071 1081 1072 //////////////////////////////1073 // データテーブルスケジュール1074 for(i=0;i<pobj_DataTableSchedule->num;i++){1075 *((long *)(OpBuffer+pobj_DataTableSchedule->pObpValues[i]))+=ImageBase+MemPos_DataSection;1076 }1077 delete pobj_DataTableSchedule;1078 1079 1080 //////////////////////////////////1081 // インポートテーブルスケジュール(インポート アドレス テーブルを指し示させる)1082 // ※x86はRVAからのオフセット。x64はRPI(実行中アドレス)からのオフセット1083 for(i=0;i<pobj_ImportAddrSchedule->num;i++){1084 const DllProc *pDllProc = pobj_ImportAddrSchedule->ppdi[i];1085 *((long *)(OpBuffer+pobj_ImportAddrSchedule->pObpValues[i]))=1086 MemPos_ImportSection+1087 pDllProc->GetLookupAddress()1088 -(MemPos_CodeSection+pobj_ImportAddrSchedule->pObpValues[i]+sizeof(long));1089 }1090 delete pobj_ImportAddrSchedule;1091 1092 1093 ////////////////////////////////////1094 // プロシージャポインタスケジュール1095 for(i=0;i<pobj_SubAddrSchedule->num;i++){1096 if(pobj_SubAddrSchedule->ppsi[i]->_beginOpAddressOld==01097 &&pobj_SubAddrSchedule->ppsi[i]->_endOpAddressOld==0){1098 SetError(300,NULL,-1);1099 }1100 1101 if(pobj_SubAddrSchedule->pbCall[i]){1102 *((long *)(OpBuffer+pobj_SubAddrSchedule->pObpValues[i]))=1103 pobj_SubAddrSchedule->ppsi[i]->_beginOpAddressOld-(pobj_SubAddrSchedule->pObpValues[i]+sizeof(long));1104 }1105 else{1106 *((long *)(OpBuffer+pobj_SubAddrSchedule->pObpValues[i]))=1107 pobj_SubAddrSchedule->ppsi[i]->_beginOpAddressOld+ImageBase+MemPos_CodeSection;1108 }1109 }1110 delete pobj_SubAddrSchedule;1111 1112 1113 1082 if( compiler.IsDll() ){ 1114 1083 //DLLの場合はリロケーション情報を生成 1115 1084 pobj_Reloc->ResetRelocBuffer(); 1116 1085 } 1117 1118 1119 1120 //////////////////////////////////////1121 // グローバル変数アドレススケジュール1122 //////////////////////////////////////1123 1124 /*1125 GlobalArea1 - 初期バッファあり1126 GlobalArea2 - 初期バッファなし1127 */1128 for(i=0;i<pobj_GlobalVarSchedule->num;i++){1129 if(*((long *)(OpBuffer+pobj_GlobalVarSchedule->pObpValues[i])) & 0x80000000){1130 //初期バッファなし1131 *((long *)(OpBuffer+pobj_GlobalVarSchedule->pObpValues[i]))=1132 AllInitGlobalVarSize+1133 (*((long *)(OpBuffer+pobj_GlobalVarSchedule->pObpValues[i])) & 0x7FFFFFFF)+1134 ImageBase+MemPos_RWSection;1135 }1136 else{1137 //初期バッファあり1138 *((long *)(OpBuffer+pobj_GlobalVarSchedule->pObpValues[i]))+=1139 ImageBase+MemPos_RWSection;1140 }1141 }1142 delete pobj_GlobalVarSchedule;1143 1144 1086 1145 1087 … … 1149 1091 compiler.linker.ResolveUserProcSchedules( MemPos_CodeSection ); 1150 1092 compiler.linker.ResolveGlobalVarSchedules( MemPos_RWSection ); 1151 1152 if( obp == compiler.linker.GetNativeCode().GetSize() ) 1153 { 1154 memcpy( OpBuffer, compiler.linker.GetNativeCode().GetCodeBuffer(), compiler.linker.GetNativeCode().GetSize() ); 1155 } 1156 else 1157 { 1158 SetError(); 1159 } 1093 compiler.linker.ResolveVtblSchedule( MemPos_DataSection ); 1160 1094 1161 1095 … … 1349 1283 memset((char *)CodeSectionHeader.Name,0,IMAGE_SIZEOF_SHORT_NAME); 1350 1284 lstrcpy((char *)CodeSectionHeader.Name,".text"); 1351 CodeSectionHeader.Misc.VirtualSize= obp;1285 CodeSectionHeader.Misc.VirtualSize= MemSize_CodeSection; 1352 1286 CodeSectionHeader.VirtualAddress= MemPos_CodeSection; //開始アドレス 1353 1287 CodeSectionHeader.SizeOfRawData= FileSize_CodeSection; … … 1546 1480 1547 1481 //コード 1548 WriteFile(hFile,OpBuffer,obp,(DWORD *)&i2,NULL); 1482 WriteFile( 1483 hFile, 1484 compiler.linker.GetNativeCode().GetBuffer(), 1485 compiler.linker.GetNativeCode().GetSize(), 1486 (DWORD *)&i2, 1487 NULL 1488 ); 1549 1489 i+=i2; 1550 1490 … … 1629 1569 if(bUse_RWSection){ 1630 1570 //リライタブル データ テーブル(グローバル変数の初期バッファ) 1631 initGlobalBuf=(BYTE *)HeapReAlloc(hHeap, 1632 HEAP_ZERO_MEMORY, 1633 initGlobalBuf, 1634 FileSize_RWSection); 1635 WriteFile(hFile,initGlobalBuf,FileSize_RWSection,(DWORD *)&i2,NULL); 1636 i+=i2; 1571 char *temp = (char *)calloc( FileSize_RWSection, 1 ); 1572 memcpy( 1573 temp, 1574 compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.GetBuffer(), 1575 compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.GetSize() 1576 ); 1577 1578 WriteFile(hFile,temp,FileSize_RWSection,(DWORD *)&i2,NULL); 1579 i+=i2; 1580 1581 free( temp ); 1637 1582 } 1638 1583 … … 1709 1654 HeapDefaultFree(pHintTable); 1710 1655 1711 //グローバル変数の初期バッファを解放1712 HeapDefaultFree(initGlobalBuf);1713 1714 //コードバッファを解放1715 free(OpBuffer);1716 OpBuffer=0;1717 1718 1656 //リソースセクションバッファを解放 1719 1657 HeapDefaultFree(RSrcSectionBuffer); -
trunk/abdev/BasicCompiler64/NumOpe.cpp
r266 r308 112 112 else if( resultType.IsWhole() || resultType.IsObject()){ 113 113 //整数型 114 SetReg_WholeVariable(resultType .GetBasicType(),&relativeVar,UseReg);114 SetReg_WholeVariable(resultType,&relativeVar,UseReg); 115 115 } 116 116 else if( resultType.IsStruct() ){ … … 132 132 return true; 133 133 } 134 bool TermMemberOpe( const CClass &objClass, const Type &baseType, Type &resultType, const char *termFull, const char *termLeft, const char *member ){ 134 bool TermMemberOpe( const Type &leftType, const Type &baseType, Type &resultType, const char *termFull, const char *termLeft, const char *member ) 135 { 136 const CClass &objClass = leftType.GetClass(); 135 137 136 138 int UseReg=pobj_reg->GetNextReg(); … … 138 140 139 141 140 if( GetMemberType( objClass, member, resultType, 0, false ) ){142 if( GetMemberType( leftType, member, resultType, 0, false ) ){ 141 143 // メンバが見つかったとき 142 144 … … 192 194 pobj_sf->push( UseReg ); 193 195 194 if( !Opcode_CallProc(parameter,pUserProc,PROCFLAG_NEW,termLeft ,0) ){196 if( !Opcode_CallProc(parameter,pUserProc,PROCFLAG_NEW,termLeft ) ){ 195 197 //レジスタ資源を復元 196 198 RESTORE_REGISTER_RESOURCE … … 284 286 } 285 287 286 return TermMemberOpe( leftType .GetClass(), baseType, resultType, termFull, termLeft, member );288 return TermMemberOpe( leftType, baseType, resultType, termFull, termLeft, member ); 287 289 } 288 290 globalArea: … … 463 465 //////////////////////////////// 464 466 465 if( Compiler::StringToType( termFull, resultType ) ){467 if( compiler.StringToType( termFull, resultType ) ){ 466 468 resultType.SetBasicType( resultType.GetBasicType() | FLAG_CAST ); 467 469 return true; … … 767 769 // As演算子の右辺値 768 770 //型名 769 if( Compiler::StringToType( term, resultType ) ){771 if( compiler.StringToType( term, resultType ) ){ 770 772 resultType.SetBasicType( resultType.GetBasicType() | FLAG_CAST ); 771 773 } -
trunk/abdev/BasicCompiler64/NumOpe_Arithmetic.cpp
r266 r308 667 667 668 668 //shl reg1,cl 669 compiler.codeGenerator.op_shl_reg( GetTypeSize(type[sp-2],-1),reg1);669 compiler.codeGenerator.op_shl_reg(Type(type[sp-2]).GetSize(),reg1); 670 670 } 671 671 else if(idCalc==CALC_SHR){ … … 674 674 675 675 //sar 676 compiler.codeGenerator.op_sar_reg( GetTypeSize(type[sp-2],-1),reg1);676 compiler.codeGenerator.op_sar_reg(Type(type[sp-2]).GetSize(),reg1); 677 677 } 678 678 else{ … … 680 680 681 681 //shr 682 compiler.codeGenerator.op_shr_reg( GetTypeSize(type[sp-2],-1),reg1);682 compiler.codeGenerator.op_shr_reg(Type(type[sp-2]).GetSize(),reg1); 683 683 } 684 684 } -
trunk/abdev/BasicCompiler64/NumOpe_Logical.cpp
r226 r308 101 101 102 102 //cmp reg,0 103 compiler.codeGenerator.op_cmp_value( GetTypeSize(type[sp-1],-1),reg,0);103 compiler.codeGenerator.op_cmp_value(Type(type[sp-1]).GetSize(),reg,0); 104 104 105 105 //setne al -
trunk/abdev/BasicCompiler64/NumOpe_TypeOperation.cpp
r266 r308 8 8 #include "Opcode.h" 9 9 10 void ExtendTypeTo64(int type,int reg){ 11 if(type==DEF_LONG){ 10 void ExtendTypeTo64( const Type &oldType, int reg ){ 11 if( oldType.IsLong() ) 12 { 12 13 //movsxd reg64,reg32 13 14 compiler.codeGenerator.op_movsxd(reg,reg); 14 15 } 15 else if(type==DEF_DWORD){ 16 else if( oldType.IsDWord() ) 17 { 16 18 //and reg,00000000FFFFFFFFh 17 19 } 18 else if(type==DEF_INTEGER || (Smoothie::IsUnicode()&&type==DEF_CHAR)){ 20 else if( oldType.IsInteger() ) 21 { 19 22 //movsx reg64,reg16 20 23 compiler.codeGenerator.op_movsx64_FromReg16(reg,reg); 21 24 } 22 else if(type==DEF_WORD){ 25 else if( oldType.IsWord() ) 26 { 23 27 //and reg,000000000000FFFFh 24 28 compiler.codeGenerator.op_and64_value(reg,(int)0xFFFF); 25 29 } 26 else if(type==DEF_SBYTE || (Smoothie::IsUnicode()==false&&type==DEF_CHAR)){ 30 else if( oldType.IsSByte() ) 31 { 27 32 //movsx reg64,reg8 28 33 compiler.codeGenerator.op_movsx64_FromReg8(reg,reg); 29 34 } 30 else if(type==DEF_BYTE || type==DEF_BOOLEAN){ 35 else if( oldType.IsByte() || oldType.IsBoolean() ) 36 { 31 37 //and reg,00000000000000FFh 32 38 compiler.codeGenerator.op_and64_value(reg,(int)0x00FF); 33 39 } 34 40 } 35 void ExtendTypeTo32(int type,int reg){ 36 if(type==DEF_INTEGER || (Smoothie::IsUnicode()&&type==DEF_CHAR)){ 41 void ExtendTypeTo32( const Type &oldType, int reg ){ 42 if( oldType.IsInteger() ) 43 { 37 44 //movsx reg32,reg16 38 45 compiler.codeGenerator.op_movsx32_FromReg16(reg,reg); 39 46 } 40 else if(type==DEF_WORD){ 47 else if( oldType.IsWord() ) 48 { 41 49 //and reg,0000FFFFh 42 50 compiler.codeGenerator.op_and32_value(reg,(int)0xFFFF); 43 51 } 44 else if(type==DEF_SBYTE || (Smoothie::IsUnicode()==false&&type==DEF_CHAR)){ 52 else if( oldType.IsSByte() ) 53 { 45 54 //movsx reg32,reg8 46 55 compiler.codeGenerator.op_movsx32_FromReg8(reg,reg); 47 56 } 48 else if(type==DEF_BYTE || type==DEF_BOOLEAN){ 57 else if( oldType.IsByte() || oldType.IsBoolean() ) 58 { 49 59 //and reg,000000FFh 50 60 compiler.codeGenerator.op_and32_value(reg,(int)0xFF); 51 61 } 52 62 } 53 void ExtendTypeTo16(int type,int reg){ 54 if(type==DEF_SBYTE || (Smoothie::IsUnicode()==false&&type==DEF_CHAR)){ 63 void ExtendTypeTo16( const Type &oldType, int reg ){ 64 if( oldType.IsSByte() ) 65 { 55 66 //movsx reg16,reg8 56 67 compiler.codeGenerator.op_movsx16_FromReg8(reg,reg); 57 68 } 58 else if(type==DEF_BYTE){ 69 else if( oldType.IsByte() || oldType.IsBoolean() ) 70 { 59 71 //and reg,000000FFh 60 72 compiler.codeGenerator.op_and32_value(reg,(int)0xFF); … … 183 195 } 184 196 185 void ChangeTypeToWhole(int OldType,int NewType,int reg,int xmm_reg){ 186 if(OldType==DEF_DOUBLE){ 187 if(Is64Type(NewType)){ 197 void ChangeTypeToWhole( const Type &oldType, const Type &newType, int reg, int xmm_reg ) 198 { 199 if( oldType.IsDouble() ) 200 { 201 if( newType.Is64() ) 202 { 188 203 //cvttsd2si reg,xmm_reg 189 204 compiler.codeGenerator.op_cvttsd2si_xmm(sizeof(_int64),reg,xmm_reg); 190 205 } 191 else{ 206 else 207 { 192 208 //cvttsd2si reg,xmm_reg 193 209 compiler.codeGenerator.op_cvttsd2si_xmm(sizeof(long),reg,xmm_reg); 194 210 } 195 211 } 196 else if(OldType==DEF_SINGLE){ 197 if(Is64Type(NewType)){ 212 if( oldType.IsSingle() ) 213 { 214 if( newType.Is64() ) 215 { 198 216 //cvttss2si reg,xmm_reg 199 217 compiler.codeGenerator.op_cvttss2si_xmm(sizeof(_int64),reg,xmm_reg); 200 218 } 201 else{ 219 else 220 { 202 221 //cvttss2si reg,xmm_reg 203 222 compiler.codeGenerator.op_cvttss2si_xmm(sizeof(long),reg,xmm_reg); … … 207 226 //整数から整数へ変換 208 227 209 if(Is64Type(NewType)){ 210 ExtendTypeTo64(OldType,reg); 211 } 212 else if(GetTypeSize(NewType,-1)==sizeof(long)){ 213 ExtendTypeTo32(OldType,reg); 214 } 215 else if(GetTypeSize(NewType,-1)==sizeof(short)){ 216 ExtendTypeTo16(OldType,reg); 228 if( newType.Is64() ) 229 { 230 ExtendTypeTo64(oldType,reg); 231 } 232 if( newType.GetSize() == sizeof(long) ) 233 { 234 ExtendTypeTo32(oldType,reg); 235 } 236 if( newType.GetSize() == sizeof(short) ) 237 { 238 ExtendTypeTo16(oldType,reg); 217 239 } 218 240 } … … 477 499 sp=*pStackPointer; 478 500 479 int CastType; 480 CastType=type[sp-1]; 481 if((CastType&FLAG_CAST)==0){ 501 int castBasicType = type[sp-1]; 502 if((castBasicType&FLAG_CAST)==0){ 482 503 SetError(47,NULL,cp); 483 504 return 0; 484 505 } 485 CastType=CastType&(~FLAG_CAST); 506 castBasicType = castBasicType&(~FLAG_CAST); 507 508 Type oldType( type[sp-2], index_stack[sp-2] ); 509 Type castType( castBasicType, index_stack[sp-1] ); 486 510 487 511 int xmm_reg,reg; 488 489 if(IsRealNumberType(CastType)){512 if( castType.IsReal() ) 513 { 490 514 //実数型へキャスト 491 515 492 if(IsRealNumberType(type[sp-2])){ 493 SetOneTermToReg_RealCalc(type[sp-2],&xmm_reg); 494 } 495 else{ 496 if(Is64Type(type[sp-2])) 497 SetOneTermToReg_Whole64Calc(type[sp-2],®); 498 else if(IsWholeNumberType(type[sp-2])) 499 SetOneTermToReg_Whole32Calc(type[sp-2],®); 516 if( oldType.IsReal() ) 517 { 518 SetOneTermToReg_RealCalc(oldType.GetBasicType(),&xmm_reg); 519 } 520 else 521 { 522 if( oldType.Is64() ) 523 { 524 SetOneTermToReg_Whole64Calc(oldType.GetBasicType(),®); 525 } 526 else if( oldType.IsWhole() ) 527 { 528 SetOneTermToReg_Whole32Calc(oldType.GetBasicType(),®); 529 } 500 530 501 531 pobj_reg->UnlockReg(); … … 504 534 } 505 535 506 if(CastType==DEF_DOUBLE){ 536 if( castType.IsDouble() ) 537 { 507 538 //Double型にデータ変換 508 ChangeTypeToXmm_Double(type[sp-2],xmm_reg,reg); 509 } 510 else if(CastType==DEF_SINGLE){ 539 ChangeTypeToXmm_Double(oldType.GetBasicType(),xmm_reg,reg); 540 } 541 else if( castType.IsSingle() ) 542 { 511 543 //Single型にデータ変換 512 ChangeTypeToXmm_Single( type[sp-2],xmm_reg,reg);544 ChangeTypeToXmm_Single(oldType.GetBasicType(),xmm_reg,reg); 513 545 } 514 546 … … 521 553 //その他整数型へ変換 522 554 523 if(IsRealNumberType(type[sp-2])){ 524 SetOneTermToReg_RealCalc(type[sp-2],&xmm_reg); 555 if( oldType.IsReal() ) 556 { 557 SetOneTermToReg_RealCalc(oldType.GetBasicType(),&xmm_reg); 525 558 526 559 pobj_reg->UnlockXmmReg(); … … 529 562 530 563 //整数型へデータ変換 531 ChangeTypeToWhole( type[sp-2],CastType,reg,xmm_reg);564 ChangeTypeToWhole(oldType,castType,reg,xmm_reg); 532 565 533 566 if(reg==REG_R14){ … … 545 578 546 579 //整数型へデータ変換 547 ChangeTypeToWhole( type[sp-2],CastType,reg,0);580 ChangeTypeToWhole(oldType,castType,reg,0); 548 581 549 582 if(reg==REG_R14){ … … 554 587 } 555 588 556 type[sp-2] =CastType;557 index_stack[sp-2] =index_stack[sp-1];589 type[sp-2] = castType.GetBasicType(); 590 index_stack[sp-2] = castType.GetIndex(); 558 591 559 592 sp--; -
trunk/abdev/BasicCompiler64/Opcode.h
r263 r308 16 16 17 17 extern int cp; 18 extern int obp;19 extern char *OpBuffer;20 18 21 19 #define breakpoint compiler.codeGenerator.PutOld( (char)0xCC ); … … 45 43 46 44 47 class CStackFrame 48 { 49 /////////////////////////// 50 // スタックフレーム管理 51 /////////////////////////// 52 53 PertialSchedules pertialSchedules; 54 55 int lowest_sp; //スタックポインタの最下位位置 56 int now_sp; //スタックポインタ 57 int max_parm_size; //パラメータの最大サイズ 58 59 public: 60 //コンストラクタ 61 CStackFrame(); 62 63 //デストラクタ 64 ~CStackFrame(); 65 66 int GetFrameSize( int localParamSize ); 67 int GetNowSp(); 68 void mov_sp( int reg ); 69 int push(int reg); 70 void push(int xmm_reg,int varSize); 71 void ref_offset_data( int reg, int sp_offset ); 72 void ref(int reg); 73 void ref(int xmm_reg,int varSize); 74 void pop(int reg = REG_NON); 75 void pop(int xmm_reg,int varSize); 76 void parameter_allocate(int size); 77 void RunningSchedule( int stackFrameSize ); 78 79 void error_check(void); 80 }; 81 extern CStackFrame *pobj_sf; 45 extern StackFrame *pobj_sf; 82 46 83 47 … … 188 152 189 153 //Compile_Calc.cpp 190 void SetVariableFromRax( int VarType,int CalcType,RELATIVE_VAR *pRelativeVar);154 void SetVariableFromRax( const Type &varType, int CalcType,RELATIVE_VAR *pRelativeVar); 191 155 void OpcodeCalc(const char *Command); 192 156 … … 224 188 225 189 //NumOpe_TypeOperation.cpp 226 void ExtendTypeTo64( int type,int reg);227 void ExtendTypeTo32( int type,int reg);228 void ExtendTypeTo16( int type,int reg);190 void ExtendTypeTo64( const Type &oldType, int reg ); 191 void ExtendTypeTo32( const Type &oldType, int reg ); 192 void ExtendTypeTo16( const Type &oldType, int reg ); 229 193 void ChangeTypeToXmm_Double(int type,int xmm_reg,int general_reg); 230 194 void ChangeTypeToXmm_Single(int type,int xmm_reg,int general_reg); 231 void ChangeTypeToWhole( int OldType,int NewType,int reg,int xmm_reg);195 void ChangeTypeToWhole( const Type &oldType, const Type &newType, int reg, int xmm_reg ); 232 196 void SetOneTermToReg_RealCalc(int TermType,int *pXmmReg); 233 197 void SetOneTermToReg_Whole64Calc(int TermType,int *pReg); … … 251 215 void SetXmmReg_DoubleVariable(RELATIVE_VAR *pRelativeVar,int xmm_reg); 252 216 void SetXmmReg_SingleVariable(RELATIVE_VAR *pRelativeVar,int xmm_reg); 253 void SetReg_WholeVariable( int type,RELATIVE_VAR *pRelativeVar,int reg);217 void SetReg_WholeVariable( const Type &type, RELATIVE_VAR *pRelativeVar,int reg); 254 218 255 219 //Compile_Interface.cpp … … 269 233 #define DIMFLAG_STATIC 0x04 270 234 #define DIMFLAG_CONST 0x08 271 void dim( char *VarName, const Subscripts &subscripts, Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags);235 void dim( char *VarName, const Subscripts &subscripts, const Type &type, const char *InitBuf,const char *ConstractParameter,DWORD dwFlags); 272 236 void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar); 273 237 bool Compile_AddGlobalRootsForGc(); … … 328 292 #define PROCFLAG_NEW 1 329 293 bool Opcode_CallProcPtr(const char *variable, const char *lpszParms,ProcPointer *pProcPointer); 330 bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName ,int RefType);294 bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName); 331 295 bool Opcode_CallDllProc( const char *lpszParms,DllProc *pDllProc); 332 296 -
trunk/abdev/BasicCompiler64/OperatorProc.cpp
r226 r308 84 84 for(int i=0;i<(int)params.size();i++){ 85 85 CheckDifferentType( 86 pUserProc->Params()[i]->GetBasicType(), 87 pUserProc->Params()[i]->GetIndex(), 88 params[i]->GetBasicType(), 89 params[i]->GetIndex(), 86 *pUserProc->Params()[i], 87 *params[i], 90 88 "", 91 89 i); … … 96 94 } 97 95 98 int right_side_size = GetTypeSize(type_stack[sp-1],index_stack[sp-1]);96 int right_side_size = Type(type_stack[sp-1],index_stack[sp-1]).GetSize(); 99 97 100 98 if(bTwoTerm){ … … 336 334 ////////////////////////////////////////////////////// 337 335 338 Opcode_CallProc(Parameter,subs[0],0,ObjectName ,DEF_OBJECT);336 Opcode_CallProc(Parameter,subs[0],0,ObjectName); 339 337 resultType = subs[0]->ReturnType(); 340 338 -
trunk/abdev/BasicCompiler64/increment.cpp
r226 r308 41 41 else{ 42 42 reg=REG_RAX; 43 SetReg_WholeVariable(varType .GetBasicType(),&VarRelativeVar,reg);43 SetReg_WholeVariable(varType,&VarRelativeVar,reg); 44 44 } 45 45 … … 94 94 //右辺値レジスタ 95 95 if(varType.IsDouble()) 96 ChangeTypeToXmm_Double(calcType.GetBasicType(), 96 { 97 ChangeTypeToXmm_Double( 98 calcType.GetBasicType(), 97 99 pobj_reg->LockXmmReg(), 98 pobj_reg->GetNextReg()); 100 pobj_reg->GetNextReg() 101 ); 102 } 99 103 else if(varType.IsSingle()) 100 ChangeTypeToXmm_Single(calcType.GetBasicType(), 104 { 105 ChangeTypeToXmm_Single( 106 calcType.GetBasicType(), 101 107 pobj_reg->LockXmmReg(), 102 pobj_reg->GetNextReg()); 108 pobj_reg->GetNextReg() 109 ); 110 } 103 111 else 104 ChangeTypeToWhole(calcType.GetBasicType(),varType.GetBasicType(), 112 { 113 ChangeTypeToWhole( 114 calcType, 115 varType, 105 116 pobj_reg->LockReg(), 106 pobj_reg->GetNextXmmReg()); 117 pobj_reg->GetNextXmmReg() 118 ); 119 } 107 120 108 121 int type_stack[255],sp; … … 159 172 } 160 173 161 SetVariableFromRax(varType .GetBasicType(),varType.GetBasicType(),&VarRelativeVar);174 SetVariableFromRax(varType,varType.GetBasicType(),&VarRelativeVar); 162 175 } -
trunk/abdev/BasicCompiler64/stack_frame.cpp
r263 r308 11 11 ///////////////////////// 12 12 13 CStackFrame::CStackFrame(){13 StackFrame::StackFrame(){ 14 14 lowest_sp=0; 15 15 now_sp=0; 16 16 max_parm_size=0; 17 17 } 18 CStackFrame::~CStackFrame(){18 StackFrame::~StackFrame(){ 19 19 //オブジェクト破棄時に不整合がないかをチェック(バグ回避) 20 20 error_check(); 21 21 } 22 int CStackFrame::GetFrameSize( int localParamSize ){22 int StackFrame::GetFrameSize( int localParamSize ){ 23 23 int answer_sp; 24 24 … … 31 31 return -(answer_sp-0x10); 32 32 } 33 int CStackFrame::GetNowSp(){33 int StackFrame::GetNowSp(){ 34 34 return now_sp; 35 35 } 36 void CStackFrame::mov_sp( int reg ){36 void StackFrame::mov_sp( int reg ){ 37 37 //mov reg,rsp 38 38 compiler.codeGenerator.op_mov_RR( reg, REG_RSP ); … … 43 43 ); 44 44 } 45 int CStackFrame::push(int reg){45 int StackFrame::push(int reg){ 46 46 now_sp-=sizeof(_int64); 47 47 if(lowest_sp>now_sp) lowest_sp=now_sp; … … 56 56 return now_sp; 57 57 } 58 void CStackFrame::push(int xmm_reg,int varSize){58 void StackFrame::push(int xmm_reg,int varSize){ 59 59 now_sp-=sizeof(_int64); 60 60 if(lowest_sp>now_sp) lowest_sp=now_sp; … … 73 73 } 74 74 } 75 void CStackFrame::ref_offset_data( int reg, int sp_offset ){75 void StackFrame::ref_offset_data( int reg, int sp_offset ){ 76 76 //mov reg,qword ptr[rsp+offset] ※スタックフレームを利用 77 77 pertialSchedules.push_back( … … 79 79 ); 80 80 } 81 void CStackFrame::ref(int reg){81 void StackFrame::ref(int reg){ 82 82 ref_offset_data( reg, now_sp ); 83 83 } 84 void CStackFrame::ref(int xmm_reg,int varSize){84 void StackFrame::ref(int xmm_reg,int varSize){ 85 85 if(varSize==sizeof(double)){ 86 86 //movlpd xmm_reg,qword ptr[rsp+offset] … … 96 96 } 97 97 } 98 void CStackFrame::pop(int reg){98 void StackFrame::pop(int reg){ 99 99 if(reg!=REG_NON) ref(reg); 100 100 101 101 now_sp+=sizeof(_int64); 102 102 } 103 void CStackFrame::pop(int xmm_reg,int varSize){103 void StackFrame::pop(int xmm_reg,int varSize){ 104 104 ref(xmm_reg,varSize); 105 105 106 106 now_sp+=sizeof(_int64); 107 107 } 108 void CStackFrame::parameter_allocate(int size){108 void StackFrame::parameter_allocate(int size){ 109 109 if(max_parm_size<size) max_parm_size=size; 110 110 } 111 void CStackFrame::RunningSchedule( int stackFrameSize ){111 void StackFrame::RunningSchedule( int stackFrameSize ){ 112 112 BOOST_FOREACH( const PertialSchedule *pPertialSchedule, pertialSchedules ) 113 113 { … … 116 116 } 117 117 118 void CStackFrame::error_check(){118 void StackFrame::error_check(){ 119 119 if(now_sp){ 120 120 SetError(300,NULL,cp); … … 123 123 124 124 //スタックフレーム管理用オブジェクトポインタ 125 CStackFrame *pobj_sf;125 StackFrame *pobj_sf; -
trunk/abdev/BasicCompiler64/stdafx.h
r218 r308 17 17 #include <boost/foreach.hpp> 18 18 19 #include <jenga/include/common/String.h> 20 19 21 #include "../BasicCompiler_Common/common.h" 22 23 #include <Compiler.h> -
trunk/abdev/BasicCompiler_Common/BasicCompiler.cpp
r302 r308 1 1 #include "stdafx.h" 2 3 #include <jenga/include/common/Path.h> 2 4 3 5 #include <jenga/include/smoothie/Smoothie.h> … … 800 802 // 出力ファイル名を絶対パスに変換 801 803 GetFullPath(OutputFileName,baseDirPath.c_str()); 804 805 // モジュール名をセット 806 compiler.SetModuleName( Jenga::Common::Path( OutputFileName ).GetFileName() ); 802 807 } 803 808 -
trunk/abdev/BasicCompiler_Common/MakeExe.cpp
r304 r308 58 58 //プログラムをファイルから読み込む 59 59 extern char SourceFileName[MAX_PATH]; 60 compiler.GetObjectModule().SetCurrentSourceIndex( compiler.GetObjectModule().GetSources().size() );60 compiler.GetObjectModule().SetCurrentSourceIndex( (int)compiler.GetObjectModule().GetSources().size() ); 61 61 compiler.GetObjectModule().GetSources().push_back( BasicSource() ); 62 62 if( !compiler.GetObjectModule().GetCurrentSource().ReadFile( SourceFileName ) ){ … … 151 151 152 152 char coreFilePath[MAX_PATH]; 153 #ifdef _AMD64_ 154 sprintf( coreFilePath, "..\\lib\\x64\\%s", coreFileName ); 155 #else 153 156 sprintf( coreFilePath, "..\\lib\\%s", coreFileName ); 157 #endif 154 158 GetFullPath( coreFilePath, szIncludeDir ); 155 159 -
trunk/abdev/BasicCompiler_Common/Subroutine.cpp
r299 r308 424 424 if(source[i]=='\0') break; 425 425 } 426 427 //////////// 428 // 特殊関数 429 //////////// 430 namespaceScopes.clear(); 431 importedNamespaces.clear(); 432 433 compiler.globalAreaProcName = "_System_GlobalArea_" + compiler.GetModuleName(); 434 sprintf(temporary,"%c%c%s()",1,ESC_SUB,compiler.globalAreaProcName.c_str()); 435 userProcs.Add( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false); 426 436 } 427 437 -
trunk/abdev/BasicCompiler_Common/VariableOpe.cpp
r301 r308 1156 1156 } 1157 1157 } 1158 1159 void DebugVariable(void) 1160 { 1161 char temporary[255]; 1162 if( compiler.GetObjectModule().meta.GetGlobalVars().Find( Symbol( "_DebugSys_dwThreadID" ) ) == NULL ) 1163 { 1164 // 未定義の場合は定義する 1165 sprintf(temporary,"_DebugSys_dwThreadID[255]%c%cDWord",1,ESC_AS); 1166 OpcodeDim(temporary,DIMFLAG_INITDEBUGVAR); 1167 sprintf(temporary,"_DebugSys_ProcNum[255]%c%cDWord",1,ESC_AS); 1168 OpcodeDim(temporary,DIMFLAG_INITDEBUGVAR); 1169 sprintf(temporary,"_DebugSys_lplpObp[255]%c%c*ULONG_PTR",1,ESC_AS); 1170 OpcodeDim(temporary,DIMFLAG_INITDEBUGVAR); 1171 sprintf(temporary,"_DebugSys_lplpSpBase[255]%c%c*ULONG_PTR",1,ESC_AS); 1172 OpcodeDim(temporary,DIMFLAG_INITDEBUGVAR); 1173 } 1174 } -
trunk/abdev/BasicCompiler_Common/VariableOpe.h
r290 r308 36 36 void dim(char *Parameter,DWORD dwFlags); 37 37 void OpcodeDim(char *Parameter,DWORD dwFlags); 38 void DebugVariable(void); -
trunk/abdev/BasicCompiler_Common/common.h
r299 r308 369 369 void SetError(); 370 370 void CompileMessage(const char *buffer); 371 bool CheckDifferentType(const int VarType,const LONG_PTR lpVarIndex,const int CalcType,const LONG_PTR lpCalcIndex,const char *pszFuncName,const int ParmNum);372 371 bool CheckDifferentType( const Type &varType,const Type &calcType,const char *pszFuncName,const int ParmNum); 373 372 … … 377 376 void SplitGenericClassInstance( const char *fullName, char *className, Jenga::Common::Strings &typeParameters ); 378 377 int JumpStatement(const char *source, int &pos); 379 void DebugVariable(void);380 378 void Compile(void); 381 379 -
trunk/abdev/BasicCompiler_Common/include/Compiler.h
r299 r308 11 11 class Compiler 12 12 { 13 // モジュール名 14 std::string moduleName; 15 13 16 // 名前空間サポート 14 17 NamespaceSupporter namespaceSupporter; … … 43 46 void StaticLink( ObjectModules &staticLibraries ); 44 47 48 // モジュール名 49 void SetModuleName( const std::string &moduleName ) 50 { 51 this->moduleName = moduleName; 52 } 53 const std::string &GetModuleName() const 54 { 55 return moduleName; 56 } 57 58 // 名前空間サポート 45 59 NamespaceSupporter &GetNamespaceSupporter() 46 60 { … … 122 136 } 123 137 138 // グローバルエリアが置かれる関数名 139 std::string globalAreaProcName; 140 124 141 125 142 bool StringToType( const std::string &typeName, Type &type ); -
trunk/abdev/BasicCompiler_Common/include/Source.h
r304 r308 50 50 int GetFileCounts() const 51 51 { 52 return filePaths.size();52 return (int)filePaths.size(); 53 53 } 54 54 … … 56 56 { 57 57 filePaths.push_back( filePath ); 58 return filePaths.size()-1;58 return (int)filePaths.size()-1; 59 59 } 60 60 void AddLine( int fileNumber ) … … 65 65 int GetLineCounts() const 66 66 { 67 return lineFileNumbers.size();67 return (int)lineFileNumbers.size(); 68 68 } 69 69 }; -
trunk/abdev/BasicCompiler_Common/src/ObjectModule.cpp
r287 r308 15 15 { 16 16 long dataSectionBaseOffset = dataTable.GetSize(); 17 int sourceIndexBase = sources.size();17 int sourceIndexBase = (int)sources.size(); 18 18 19 19 // メタ情報を結合 -
trunk/abdev/ProjectEditor/Common.h
r302 r308 66 66 #define APPLICATION_NAME "ActiveBasic 5.0" 67 67 #define VERSION_APPLI_NAME APPLICATION_NAME 68 #define VERSION_STRING "5.00.00 (rev. 299)"68 #define VERSION_STRING "5.00.00 (rev.317)" 69 69 70 70 #endif -
trunk/abdev/ProjectEditor/ExtensionLink.cpp
r302 r308 525 525 hKey=ClassRoot_CreateKey(temp2,temp3); 526 526 527 sprintf(temp2," %s file.",pobj_nv->pobj_ExtLink->ppobj_ExtItems[i]->m_szExtension);527 sprintf(temp2,"text/plain",pobj_nv->pobj_ExtLink->ppobj_ExtItems[i]->m_szExtension); 528 528 RegSetValueEx(hKey,"Content Type",0,REG_SZ,(const unsigned char *)temp2,lstrlen(temp2)); 529 529
Note:
See TracChangeset
for help on using the changeset viewer.