Changeset 140 in dev
- Timestamp:
- Jun 15, 2007, 4:00:25 AM (17 years ago)
- Files:
-
- 3 added
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler32/BasicCompiler.vcproj
r135 r140 146 146 Name="VCCLCompilerTool" 147 147 Optimization="2" 148 InlineFunctionExpansion="1" 148 InlineFunctionExpansion="2" 149 FavorSizeOrSpeed="1" 149 150 AdditionalIncludeDirectories="..\cpplibs\boost;..\BasicCompiler_Common\include" 150 151 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;JPN" … … 1840 1841 <File 1841 1842 RelativePath="..\BasicCompiler_Common\src\Prototype.cpp" 1843 > 1844 </File> 1845 <File 1846 RelativePath="..\BasicCompiler_Common\src\Symbol.cpp" 1842 1847 > 1843 1848 </File> … … 1952 1957 > 1953 1958 <File 1959 RelativePath="..\BasicCompiler_Common\include\logger.h" 1960 > 1961 </File> 1962 <File 1954 1963 RelativePath="..\BasicCompiler_Common\include\Namespace.h" 1955 1964 > … … 1961 1970 <File 1962 1971 RelativePath="..\BasicCompiler_Common\Procedure.h" 1972 > 1973 </File> 1974 <File 1975 RelativePath="..\BasicCompiler_Common\include\Symbol.h" 1963 1976 > 1964 1977 </File> -
BasicCompiler32/Compile_Object.cpp
r135 r140 59 59 if( subs.size() == 1 ){ 60 60 char temporary[VN_SIZE]; 61 sprintf( temporary, " _System_TypeBase.Search(\"\",\"%s\"))", pobj_c->GetName().c_str() );61 sprintf( temporary, "ActiveBasic.Core._System_TypeBase.Search(\"\",\"%s\"))", pobj_c->GetName().c_str() ); 62 62 63 63 Opcode_CallProc(temporary, -
BasicCompiler32/Compile_ProcOp.cpp
r135 r140 514 514 } 515 515 516 //新しいオブジェクト領域は0で初期化されているため、Nothingを明示的に代入する必要はない517 /*518 //実体クラスを持つメンバのコンストラクタ(引数有りを除く)を呼び出す519 for(i3=0;i3<pobj_CompilingClass->iMemberNum;i3++){520 CMember *pMember = pobj_CompilingClass->ppobj_Member[i3];521 if(pMember->IsObject()){522 // オブジェクトメンバを発見したとき523 524 sprintf(temporary, "This.%s=Nothing",525 pMember->name );526 OpcodeCalc( temporary );527 }528 }529 */530 531 516 //仮想関数テーブルを初期化 532 517 if(pobj_CompilingClass->vtbl_num&& … … 608 593 } 609 594 } 610 611 //実体クラスを持つメンバのデストラクタ呼び出しはGCに任せる612 /*613 //※コンストラクタと逆順序で呼び出す614 int offset;615 int MemberTypeSize;616 int MemberObjectNum;617 offset=GetTypeSize(DEF_OBJECT,(LONG_PTR)pobj_CompilingClass);618 for(i3=pobj_CompilingClass->iMemberNum-1;i3>=0;i3--){619 CMember *pMember = pobj_CompilingClass->ppobj_Member[i3];620 621 MemberTypeSize=622 GetTypeSize(pMember->TypeInfo.type,623 pMember->TypeInfo.u.lpIndex);624 625 MemberObjectNum=626 JumpSubScripts(pMember->SubScripts);627 628 offset-=MemberTypeSize*MemberObjectNum;629 630 if(pMember->TypeInfo.type==DEF_OBJECT){631 CMethod *method = pMember->TypeInfo.u.pobj_Class->GetDestructorMethod();632 if( method ){633 for(i4=MemberObjectNum-1;i4>=0;i4--){634 //Thisポインタをecxにコピー635 SetThisPtrToReg(REG_ECX);636 637 //add ecx,offset638 OpBuffer[obp++]=(char)0x81;639 OpBuffer[obp++]=(char)0xC1;640 *((long *)(OpBuffer+obp))=offset+i4*MemberTypeSize;641 obp+=sizeof(long);642 643 //push ecx644 op_push(REG_ECX);645 646 //call destructor647 op_call( method->pUserProc );648 }649 }650 }651 }*/652 595 } 653 596 } -
BasicCompiler32/Compile_Var.cpp
r138 r140 158 158 } 159 159 bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const CClass &objClass, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess){ 160 int i;161 162 160 163 161 ////////////////////////////////////// … … 178 176 //////////////////////////// 179 177 180 int offset = objClass.GetMemberOffset( VarName, &i ); 181 if(i==objClass.iMemberNum){ 178 int memberIndex; 179 int offset = objClass.GetMemberOffset( VarName, &memberIndex ); 180 if(memberIndex==objClass.GetDynamicMembers().size()){ 182 181 if(isErrorEnabled) SetError(103,VarName,cp); 183 182 return false; 184 183 } 185 184 186 CMember *pMember=objClass. ppobj_Member[i];185 CMember *pMember=objClass.GetDynamicMembers()[memberIndex]; 187 186 188 187 … … 351 350 352 351 bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType,int *pss){ 353 int i;354 352 char variable[VN_SIZE]; 355 353 … … 387 385 ////////////////// 388 386 389 const Variable *pVar = UserProc::CompilingUserProc().localVars.BackSearch( VarName);387 const Variable *pVar = UserProc::CompilingUserProc().localVars.BackSearch( Symbol( VarName ) ); 390 388 if( pVar ){ 391 389 //ポインタ変数の場合 … … 444 442 //クラス内メンバを参照するとき(通常) 445 443 446 for(i=0;i<pobj_CompilingClass->iMemberNum;i++){ 447 if( pobj_CompilingClass->ppobj_Member[i]->GetName() == VarName ){ 444 bool isFound = false; 445 BOOST_FOREACH( CMember *pMember, pobj_CompilingClass->GetDynamicMembers() ){ 446 if( pMember->GetName() == VarName ){ 447 isFound = true; 448 448 break; 449 449 } 450 450 } 451 if( i==pobj_CompilingClass->iMemberNum) goto NonClassMember;451 if( !isFound ) goto NonClassMember; 452 452 } 453 453 … … 494 494 GetNowStaticVarFullName(VarName,temporary); 495 495 496 pVar = globalVars.Find( temporary);496 pVar = globalVars.Find( Symbol( temporary ) ); 497 497 if( pVar ){ 498 498 goto GlobalOk; … … 525 525 char temp2[VN_SIZE]; 526 526 sprintf(temp2,"%s.%s",VarName,temporary); 527 pVar = globalVars.Find( temp2);527 pVar = globalVars.Find( Symbol( temp2 ) ); 528 528 if( pVar ){ 529 529 lstrcpy(member,tempMember); … … 537 537 char temp2[VN_SIZE]; 538 538 sprintf(temp2,"%s.%s",pobj_CompilingClass->GetName().c_str(),VarName); 539 pVar = globalVars.Find( temp2);539 pVar = globalVars.Find( Symbol( temp2 ) ); 540 540 if( pVar ){ 541 541 goto GlobalOk; … … 547 547 ///////////////////// 548 548 549 pVar = globalVars.BackSearch( VarName);549 pVar = globalVars.BackSearch( Symbol( VarName ) ); 550 550 if( pVar ){ 551 551 goto GlobalOk; … … 716 716 bool SetInitGlobalData(int offset,const Type &type,const int *SubScripts,const char *lpszInitBuf){ 717 717 extern BYTE *initGlobalBuf; 718 int i ,i2,i3;718 int i2,i3; 719 719 char temporary[VN_SIZE]; 720 720 char InitBuf[VN_SIZE]; … … 729 729 if(SubScripts[0]!=-1){ 730 730 typeSize*=JumpSubScripts(SubScripts+1); 731 i =0;731 int i=0; 732 732 i2=0; 733 733 while(1){ … … 751 751 const CClass &objClass = type.GetClass(); 752 752 753 for(i=0,i2=0;i2<objClass.iMemberNum;i2++){ 753 int i = 0; 754 BOOST_FOREACH( CMember *pMember, objClass.GetDynamicMembers() ){ 755 if(InitBuf[i]=='\0'){ 756 SetError(41,0,cp); 757 return false; 758 } 759 754 760 i=GetOneParameter(InitBuf,i,temporary); 755 761 756 i3=objClass.GetMemberOffset( objClass.ppobj_Member[i2]->GetName().c_str(), NULL );762 i3=objClass.GetMemberOffset( pMember->GetName().c_str(), NULL ); 757 763 758 764 if(!SetInitGlobalData(offset+i3, 759 objClass.ppobj_Member[i2]->GetType(),760 objClass.ppobj_Member[i2]->SubScripts,765 pMember->GetType(), 766 pMember->SubScripts, 761 767 temporary)) return false; 762 763 if(InitBuf[i]=='\0') break;764 }765 if(i2+1!=objClass.iMemberNum){766 SetError(41,0,cp);767 return false;768 768 } 769 769 return true; … … 889 889 const CClass &objClass = type.GetClass(); 890 890 891 for(i=0,i2=0;i2<objClass.iMemberNum;i2++){ 891 int i = 0; 892 BOOST_FOREACH( CMember *pMember, objClass.GetDynamicMembers() ){ 893 if(InitBuf[i]=='\0'){ 894 SetError(41,0,cp); 895 return false; 896 } 897 892 898 i=GetOneParameter(InitBuf,i,temporary); 893 899 894 i3=objClass.GetMemberOffset( objClass.ppobj_Member[i2]->GetName().c_str(), NULL );900 i3=objClass.GetMemberOffset( pMember->GetName().c_str(), NULL ); 895 901 896 902 if(!InitLocalVar(offset+i3, 897 objClass.ppobj_Member[i2]->GetType(),898 objClass.ppobj_Member[i2]->SubScripts,903 pMember->GetType(), 904 pMember->SubScripts, 899 905 temporary)) return false; 900 906 901 907 if(InitBuf[i]=='\0') break; 902 }903 if(i2+1!=objClass.iMemberNum){904 SetError(41,0,cp);905 return 0;906 908 } 907 909 return true; … … 1078 1080 ///////////////// 1079 1081 1080 if( UserProc::CompilingUserProc().localVars.DuplicateCheck( VarName) ){1082 if( UserProc::CompilingUserProc().localVars.DuplicateCheck( Symbol( VarName ) ) ){ 1081 1083 //2重定義のエラー 1082 1084 SetError(15,VarName,cp); -
BasicCompiler32/MakePeHdr.cpp
r105 r140 259 259 pSub_System_GC_free_for_SweepingDelete->Using(); 260 260 261 if( pSubStaticMethod_System_TypeBase_InitializeUserTypes = GetSubHash( " _System_TypeBase.InitializeUserTypes",1 ) ){261 if( pSubStaticMethod_System_TypeBase_InitializeUserTypes = GetSubHash( "ActiveBasic.Core._System_TypeBase.InitializeUserTypes",1 ) ){ 262 262 pSubStaticMethod_System_TypeBase_InitializeUserTypes->Using(); 263 263 pSubStaticMethod_System_TypeBase_InitializeUserTypes->ThisIsAutoGenerationProc(); -
BasicCompiler32/Opcode.h
r138 r140 232 232 233 233 private: 234 bool _overload_check( int level, const Parameters &targetParms, const Type &targetResultType ); 235 UserProc *OverloadSolutionWithReturnType( const char *name, std::vector<UserProc *> &subs ); 234 bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType ); 236 235 public: 237 UserProc *OverloadSolution( const char *name, std::vector<UserProc *> &subs ); 236 UserProc *_OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType = false ); 237 UserProc *OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType = false ); 238 238 239 239 void ApplyDefaultParameters( const Parameters ¶ms ); -
BasicCompiler64/BasicCompiler.vcproj
r137 r140 350 350 Name="VCCLCompilerTool" 351 351 Optimization="2" 352 InlineFunctionExpansion="2" 353 FavorSizeOrSpeed="1" 352 354 AdditionalIncludeDirectories="..\cpplibs\boost;..\BasicCompiler_Common\include" 353 355 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;JPN;_AMD64_;_WIN64" … … 480 482 > 481 483 <File 484 RelativePath="..\BasicCompiler_Common\include\logger.h" 485 > 486 </File> 487 <File 482 488 RelativePath="..\BasicCompiler_Common\include\Namespace.h" 483 489 > … … 489 495 <File 490 496 RelativePath="..\BasicCompiler_Common\Procedure.h" 497 > 498 </File> 499 <File 500 RelativePath="..\BasicCompiler_Common\include\Symbol.h" 491 501 > 492 502 </File> … … 1592 1602 </File> 1593 1603 <File 1604 RelativePath="..\BasicCompiler_Common\src\Symbol.cpp" 1605 > 1606 </File> 1607 <File 1594 1608 RelativePath="..\BasicCompiler_Common\Type.cpp" 1595 1609 > -
BasicCompiler64/Compile_Object.cpp
r135 r140 57 57 if( subs.size() == 1 ){ 58 58 char temporary[VN_SIZE]; 59 sprintf( temporary, " _System_TypeBase.Search(\"\",\"%s\"))", pobj_c->GetName().c_str() );59 sprintf( temporary, "ActiveBasic.Core._System_TypeBase.Search(\"\",\"%s\"))", pobj_c->GetName().c_str() ); 60 60 61 61 Opcode_CallProc(temporary, -
BasicCompiler64/Compile_ProcOp.cpp
r135 r140 566 566 } 567 567 568 //新しいオブジェクト領域は0で初期化されているため、Nothingを明示的に代入する必要はない569 /*570 //実体クラスを持つメンバのコンストラクタ(引数有りを除く)を呼び出す571 for(i3=0;i3<pobj_CompilingClass->iMemberNum;i3++){572 CMember *pMember = pobj_CompilingClass->ppobj_Member[i3];573 if(pMember->IsObject()){574 // オブジェクトメンバを発見したとき575 576 sprintf(temporary, "This.%s=Nothing",577 pMember->name );578 OpcodeCalc( temporary );579 }580 }581 */582 583 568 //仮想関数テーブルを初期化 584 569 if(pobj_CompilingClass->vtbl_num&& … … 659 644 } 660 645 } 661 662 //実体クラスを持つメンバのデストラクタ呼び出しはGCに任せる663 /*664 //※コンストラクタと逆順序で呼び出す665 for(i3=pobj_CompilingClass->iMemberNum-1;i3>=0;i3--){666 CMember *pMember = pobj_CompilingClass->ppobj_Member[i3];667 int MemberTypeSize=668 GetTypeSize(pMember->TypeInfo.type,669 pMember->TypeInfo.u.lpIndex);670 671 int MemberObjectNum=672 JumpSubScripts(pMember->SubScripts);673 674 int offset = pobj_CompilingClass->GetMemberOffset( pMember->name, NULL );675 676 if(pMember->IsObject()){677 CMethod *method = pMember->GetClass().GetDestructorMethod();678 if( method ){679 for(i4=MemberObjectNum-1;i4>=0;i4--){680 //Thisポインタをrcxにコピー681 SetThisPtrToReg(REG_RCX);682 683 //add rcx,offset684 op_add_RV(REG_RCX,offset+i4*MemberTypeSize);685 686 //call destructor687 op_call(method->pUserProc);688 }689 }690 }691 }*/692 646 } 693 647 } -
BasicCompiler64/Compile_Var.cpp
r138 r140 187 187 } 188 188 bool _member_offset(bool isErrorEnabled, bool isWriteAccess, const CClass &objClass, const char *member, RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess){ 189 int i;190 191 189 192 190 ////////////////////////////////////// … … 207 205 //////////////////////////// 208 206 209 int offset = objClass.GetMemberOffset( VarName, &i ); 210 if(i==objClass.iMemberNum){ 207 int memberIndex; 208 int offset = objClass.GetMemberOffset( VarName, &memberIndex ); 209 if( memberIndex == objClass.GetDynamicMembers().size() ){ 211 210 if(isErrorEnabled) SetError(103,VarName,cp); 212 211 return false; 213 212 } 214 213 215 CMember *pMember =objClass.ppobj_Member[i];214 CMember *pMember = objClass.GetDynamicMembers()[memberIndex]; 216 215 217 216 … … 379 378 } 380 379 bool GetVarOffset(bool isErrorEnabled,bool isWriteAccess,const char *NameBuffer,RELATIVE_VAR *pRelativeVar,Type &resultType,int *pss){ 381 int i;382 380 char variable[VN_SIZE]; 383 381 … … 471 469 //クラス内メンバを参照するとき(通常) 472 470 473 for(i=0;i<pobj_CompilingClass->iMemberNum;i++){ 474 if( pobj_CompilingClass->ppobj_Member[i]->GetName() == VarName ){ 471 bool isFound = false; 472 BOOST_FOREACH( CMember *pMember, pobj_CompilingClass->GetDynamicMembers() ){ 473 if( pMember->GetName() == VarName ){ 474 isFound = true; 475 475 break; 476 476 } 477 477 } 478 if( i==pobj_CompilingClass->iMemberNum) goto NonClassMember;478 if( !isFound ) goto NonClassMember; 479 479 } 480 480 … … 773 773 const CClass &objClass = type.GetClass(); 774 774 775 for(i=0,i2=0;i2<objClass.iMemberNum;i2++){ 775 int i = 0; 776 BOOST_FOREACH( CMember *pMember, objClass.GetDynamicMembers() ){ 777 if(InitBuf[i]=='\0'){ 778 SetError(41,0,cp); 779 return false; 780 } 781 776 782 i=GetOneParameter(InitBuf,i,temporary); 777 783 778 i3=objClass.GetMemberOffset( objClass.ppobj_Member[i2]->GetName().c_str(), NULL );784 i3=objClass.GetMemberOffset( pMember->GetName().c_str(), NULL ); 779 785 780 786 if(!SetInitGlobalData(offset+i3, 781 objClass.ppobj_Member[i2]->GetType(),782 objClass.ppobj_Member[i2]->SubScripts,787 pMember->GetType(), 788 pMember->SubScripts, 783 789 temporary)) return false; 784 785 if(InitBuf[i]=='\0') break;786 }787 if(i2+1!=objClass.iMemberNum){788 SetError(41,0,cp);789 return false;790 790 } 791 791 return true; … … 911 911 const CClass &objClass = type.GetClass(); 912 912 913 for(i=0,i2=0;i2<objClass.iMemberNum;i2++){ 913 int i = 0; 914 BOOST_FOREACH( CMember *pMember, objClass.GetDynamicMembers() ){ 915 if(InitBuf[i]=='\0'){ 916 SetError(41,0,cp); 917 return false; 918 } 919 914 920 i=GetOneParameter(InitBuf,i,temporary); 915 921 916 i3=objClass.GetMemberOffset( objClass.ppobj_Member[i2]->GetName().c_str(), NULL );922 i3=objClass.GetMemberOffset( pMember->GetName().c_str(), NULL ); 917 923 918 924 if(!InitLocalVar(offset+i3, 919 objClass.ppobj_Member[i2]->GetType(),920 objClass.ppobj_Member[i2]->SubScripts,925 pMember->GetType(), 926 pMember->SubScripts, 921 927 temporary)) return false; 922 928 923 929 if(InitBuf[i]=='\0') break; 924 }925 if(i2+1!=objClass.iMemberNum){926 SetError(41,0,cp);927 return 0;928 930 } 929 931 return true; -
BasicCompiler64/MakePeHdr.cpp
r129 r140 240 240 pSub_System_GC_free_for_SweepingDelete->Using(); 241 241 242 if( pSubStaticMethod_System_TypeBase_InitializeUserTypes = GetSubHash( " _System_TypeBase.InitializeUserTypes",1 ) ){242 if( pSubStaticMethod_System_TypeBase_InitializeUserTypes = GetSubHash( "ActiveBasic.Core._System_TypeBase.InitializeUserTypes",1 ) ){ 243 243 pSubStaticMethod_System_TypeBase_InitializeUserTypes->Using(); 244 244 pSubStaticMethod_System_TypeBase_InitializeUserTypes->ThisIsAutoGenerationProc(); -
BasicCompiler64/NumOpe.cpp
r135 r140 524 524 //New演算子(オブジェクト生成) 525 525 526 if( !Operator_New( expression+2, baseType, resultType ) ){ 527 return false; 528 } 526 if( pobj_BlockReg->check(REG_RAX) ){ 527 SetError(); 528 } 529 530 ////////////////////////////////////////////////////// 531 ///// レジスタ資源のバックアップ 532 { BACKUP_REGISTER_RESOURCE 533 ////////////////////////////////////////////////////// 534 535 if( !Operator_New( expression+2, baseType, resultType ) ){ 536 return false; 537 } 538 539 ///////////////////////////////////////////// 540 ////// レジスタ資源を復元 541 RESTORE_REGISTER_RESOURCE 542 }//////////////////////////////////////////// 529 543 530 544 //mov reg,rax -
BasicCompiler64/Opcode.h
r138 r140 353 353 354 354 private: 355 bool _overload_check( int level, const Parameters ¶ms, const Type &returnType );356 UserProc *OverloadSolutionWithReturnType( const char *name, std::vector<UserProc *> &subs ); 355 bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType ); 356 357 357 public: 358 UserProc *OverloadSolution( const char *name, std::vector<UserProc *> &subs ); 358 UserProc *_OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType = false ); 359 UserProc *OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType = false ); 359 360 360 361 void ApplyDefaultParameters( const Parameters ¶ms ); -
BasicCompiler_Common/BasicCompiler.cpp
r139 r140 548 548 549 549 //MessageBox(0,"starting compiler/debugger","ActiveBasic",MB_OK); 550 trace( "Start ActiveBasic Compiler!" ); 550 551 551 552 //コモンコントロールを初期化 … … 840 841 } 841 842 843 trace("Complete ActiveBasic Compiler!"); 844 842 845 843 846 return 0; -
BasicCompiler_Common/Class.cpp
r139 r140 15 15 16 16 CClass::CClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name ) 17 : Prototype( namespaceScopes, name ) 17 : isReady( false ) 18 , Prototype( namespaceScopes, name ) 18 19 , importedNamespaces( importedNamespaces ) 19 20 , ConstructorMemberSubIndex( 0 ) … … 21 22 , classType( Class ) 22 23 , pobj_InheritsClass( NULL ) 23 , ppobj_Member( NULL )24 , iMemberNum( 0 )25 24 , vtbl_num( 0 ) 26 25 , iAlign( 0 ) … … 32 31 } 33 32 CClass::~CClass(){ 34 int i; 35 36 if(ppobj_Member){ 37 //メンバ 38 for(i=0;i<iMemberNum;i++){ 39 delete ppobj_Member[i]; 40 } 41 HeapDefaultFree(ppobj_Member); 42 ppobj_Member=0; 43 } 44 45 //静的メンバ 33 // 動的メンバ 34 foreach( CMember *member, dynamicMembers ){ 35 delete member; 36 } 37 38 // 静的メンバ 46 39 foreach( CMember *member, staticMembers ){ 47 40 delete member; … … 149 142 } 150 143 151 if( inheritsClass.ppobj_Member == 0){144 if( !inheritsClass.IsReady() ){ 152 145 //継承先が読み取られていないとき 153 146 pobj_LoopRefCheck->add(this->GetName().c_str()); … … 157 150 158 151 //メンバをコピー 159 ppobj_Member=(CMember **)HeapReAlloc( 160 hHeap, 161 0, 162 ppobj_Member, 163 ( iMemberNum + inheritsClass.iMemberNum )*sizeof(CMember *)); 164 for(int i3=0;i3<inheritsClass.iMemberNum;i3++){ 165 ppobj_Member[iMemberNum]=new CMember( *inheritsClass.ppobj_Member[i3] ); 152 BOOST_FOREACH( CMember *inheritsClassDynamicMember, inheritsClass.dynamicMembers ){ 153 CMember *pMember = new CMember( *inheritsClassDynamicMember ); 166 154 167 155 // アクセシビリティ 168 if( inheritsClass .ppobj_Member[i3]->IsPrivate() ){169 p pobj_Member[iMemberNum]->SetAccessibility( Prototype::None );156 if( inheritsClassDynamicMember->IsPrivate() ){ 157 pMember->SetAccessibility( Prototype::None ); 170 158 } 171 159 else{ 172 p pobj_Member[iMemberNum]->SetAccessibility( inheritsClass.ppobj_Member[i3]->GetAccessibility() );173 } 174 175 iMemberNum++;160 pMember->SetAccessibility( inheritsClassDynamicMember->GetAccessibility() ); 161 } 162 163 dynamicMembers.push_back( pMember ); 176 164 } 177 165 … … 216 204 } 217 205 218 if( inheritsInterface.ppobj_Member == 0){206 if( !inheritsInterface.IsReady() ){ 219 207 //継承先が読み取られていないとき 220 208 pobj_LoopRefCheck->add(this->GetName().c_str()); … … 255 243 } 256 244 void CClass::AddMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer ){ 257 ppobj_Member = (CMember **)HeapReAlloc( hHeap, 0, ppobj_Member, ( iMemberNum + 1 ) * sizeof(CMember *) ); 258 ppobj_Member[iMemberNum] = new CMember( this, accessibility, isConst, isRef, buffer ); 259 iMemberNum++; 245 CMember *pMember = new CMember( this, accessibility, isConst, isRef, buffer ); 246 dynamicMembers.push_back( pMember ); 260 247 } 261 248 void CClass::AddStaticMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ){ 262 CMember * member = new CMember( this, accessibility, isConst, isRef, buffer, nowLine );263 staticMembers.push_back( member );249 CMember *pMember = new CMember( this, accessibility, isConst, isRef, buffer, nowLine ); 250 staticMembers.push_back( pMember ); 264 251 } 265 252 BOOL CClass::DupliCheckAll(const char *name){ … … 281 268 //重複チェック 282 269 283 // メンバ284 for( int i=0;i<iMemberNum;i++){285 if( GetName() == p pobj_Member[i]->GetName() ){270 // 動的メンバ 271 BOOST_FOREACH( CMember *pMember, dynamicMembers ){ 272 if( GetName() == pMember->GetName() ){ 286 273 return 1; 287 274 } 288 275 } 289 276 290 // 静的メンバ291 foreach( CMember * member, staticMembers ){292 if( GetName() == member->GetName() ){277 // 静的メンバ 278 foreach( CMember *pMember, staticMembers ){ 279 if( GetName() == pMember->GetName() ){ 293 280 return 1; 294 281 } … … 321 308 int CClass::GetMemberOffset( const char *memberName, int *pMemberNum ) const 322 309 { 323 int i ,i2,offset;310 int i2,offset; 324 311 325 312 //仮想関数が存在する場合は関数リストへのポインタのサイズを追加 … … 332 319 333 320 int iMaxAlign=0; 334 for(i=0;i<iMemberNum;i++){ 335 CMember *pMember = ppobj_Member[i]; 321 int i = -1; 322 BOOST_FOREACH( CMember *pMember, dynamicMembers ){ 323 i++; 336 324 337 325 i2 = pMember->GetType().GetSize(); … … 393 381 int CClass::GetAlignment() const 394 382 { 395 int i;396 383 int alignment,member_size; 397 384 … … 399 386 else alignment=0; 400 387 401 for(i=0;i<iMemberNum;i++){ 402 CMember *pMember = ppobj_Member[i]; 403 388 BOOST_FOREACH( CMember *pMember, dynamicMembers ){ 404 389 if(pMember->GetType().IsStruct()){ 405 390 //メンバクラスのアラインメントを取得 … … 969 954 970 955 BOOL CDBClass::MemberVar_LoopRefCheck(const CClass &objClass){ 971 int i,i2,bRet=1; 972 for(i=0;i<objClass.iMemberNum;i++){ 973 const CMember *pMember = objClass.ppobj_Member[i]; 956 int i2,bRet=1; 957 BOOST_FOREACH( CMember *pMember, objClass.dynamicMembers ){ 974 958 if(pMember->GetType().IsStruct()){ 975 959 //循環参照でないかをチェック … … 1055 1039 } 1056 1040 1057 if(pobj_c-> ppobj_Member){1041 if(pobj_c->IsReady()){ 1058 1042 //既に先読みされているとき 1059 1043 continue; 1060 1044 } 1061 1045 1062 //メンバ用メモリを初期化 1063 pobj_c->ppobj_Member=(CMember **)HeapAlloc(hHeap,0,1); 1064 pobj_c->iMemberNum=0; 1046 pobj_c->Readed(); 1065 1047 1066 1048 pobj_c->ConstructorMemberSubIndex=-1; … … 1206 1188 } 1207 1189 1208 if(pobj_c-> ppobj_Member){1190 if(pobj_c->IsReady()){ 1209 1191 //既に先読みされているとき 1210 1192 continue; … … 1213 1195 pobj_c->iAlign=iAlign; 1214 1196 1215 //メンバ用メモリを初期化 1216 pobj_c->ppobj_Member=(CMember **)HeapAlloc(hHeap,0,1); 1217 pobj_c->iMemberNum=0; 1197 pobj_c->Readed(); 1218 1198 1219 1199 pobj_c->ConstructorMemberSubIndex=-1; … … 1381 1361 1382 1362 1383 if(pobj_c-> ppobj_Member[pobj_c->iMemberNum-1]->GetType().IsStruct()){1384 if( pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->GetType().GetClass().ppobj_Member==0){1363 if(pobj_c->dynamicMembers[pobj_c->dynamicMembers.size()-1]->GetType().IsStruct()){ 1364 if( !pobj_c->dynamicMembers[pobj_c->dynamicMembers.size()-1]->GetType().GetClass().IsReady() ){ 1385 1365 //参照先が読み取られていないとき 1386 GetClass_recur(pobj_c-> ppobj_Member[pobj_c->iMemberNum-1]->GetType().GetClass().GetName().c_str());1366 GetClass_recur(pobj_c->dynamicMembers[pobj_c->dynamicMembers.size()-1]->GetType().GetClass().GetName().c_str()); 1387 1367 } 1388 1368 } 1389 1369 1390 1370 1391 if(pobj_c-> ppobj_Member[pobj_c->iMemberNum-1]->GetType().IsStruct()){1371 if(pobj_c->dynamicMembers[pobj_c->dynamicMembers.size()-1]->GetType().IsStruct()){ 1392 1372 //循環参照のチェック 1393 1373 pobj_LoopRefCheck->add(pobj_c->GetName().c_str()); 1394 if(!MemberVar_LoopRefCheck(pobj_c-> ppobj_Member[pobj_c->iMemberNum-1]->GetType().GetClass())){1374 if(!MemberVar_LoopRefCheck(pobj_c->dynamicMembers[pobj_c->dynamicMembers.size()-1]->GetType().GetClass())){ 1395 1375 //エラー回避 1396 pobj_c-> ppobj_Member[pobj_c->iMemberNum-1]->GetType().SetBasicType( DEF_PTR_VOID );1376 pobj_c->dynamicMembers[pobj_c->dynamicMembers.size()-1]->GetType().SetBasicType( DEF_PTR_VOID ); 1397 1377 } 1398 1378 pobj_LoopRefCheck->del(pobj_c->GetName().c_str()); … … 1481 1461 char referenceOffsetsBuffer[1024] = ""; 1482 1462 int numOfReference = 0; 1483 for( int i=0; i<objClass.iMemberNum; i++ ){ 1484 CMember &member = *objClass.ppobj_Member[i]; 1485 1486 if( member.GetType().IsObject() || member.GetType().IsPointer() ){ 1463 BOOST_FOREACH( CMember *pMember, objClass.dynamicMembers ){ 1464 if( pMember->GetType().IsObject() || pMember->GetType().IsPointer() ){ 1487 1465 if( referenceOffsetsBuffer[0] ){ 1488 1466 lstrcat( referenceOffsetsBuffer, "," ); … … 1491 1469 sprintf( referenceOffsetsBuffer + lstrlen( referenceOffsetsBuffer ), 1492 1470 "%d", 1493 objClass.GetMemberOffset( member.GetName().c_str() ) );1471 objClass.GetMemberOffset( pMember->GetName().c_str() ) ); 1494 1472 1495 1473 numOfReference++; -
BasicCompiler_Common/Class.h
r137 r140 38 38 friend CDebugSection; 39 39 40 bool isReady; 41 void Readed(){ 42 isReady = true; 43 } 44 bool IsReady() const{ 45 return isReady; 46 } 47 40 48 // importされている名前空間 41 49 NamespaceScopesCollection importedNamespaces; … … 47 55 Type blittableType; 48 56 49 //静的メンバ情報 50 std::vector<CMember *> staticMembers; 51 52 //メソッド情報 57 // 動的メンバ 58 Members dynamicMembers; 59 60 // 静的メンバ 61 Members staticMembers; 62 63 // 動的メソッド 53 64 Methods methods; 54 65 int ConstructorMemberSubIndex; 55 66 int DestructorMemberSubIndex; 56 67 57 // 静的メソッド情報68 // 静的メソッド 58 69 Methods staticMethods; 59 70 … … 73 84 const CClass *pobj_InheritsClass; 74 85 75 //メンバ情報76 CMember **ppobj_Member;77 int iMemberNum;78 79 86 //仮想関数の数 80 87 int vtbl_num; … … 129 136 BOOL DupliCheckAll(const char *name); 130 137 BOOL DupliCheckMember(const char *name); 138 139 const Members &GetDynamicMembers() const 140 { 141 return dynamicMembers; 142 } 131 143 132 144 const Methods &GetMethods() const -
BasicCompiler_Common/DebugMiddleFile.cpp
r137 r140 50 50 void CDebugSection::make(void){ 51 51 extern INCLUDEFILEINFO IncludeFileInfo; 52 int i2,i3,i 4,i5,BufferSize;52 int i2,i3,i5,BufferSize; 53 53 54 54 if(buffer){ … … 324 324 325 325 //メンバ 326 *(long *)(buffer+i2)= pobj_c->iMemberNum;327 i2+=sizeof(long); 328 for (i4=0;i4<pobj_c->iMemberNum;i4++){326 *(long *)(buffer+i2)=(int)pobj_c->dynamicMembers.size(); 327 i2+=sizeof(long); 328 foreach( CMember *member, pobj_c->dynamicMembers ){ 329 329 // 名前 330 lstrcpy(buffer+i2, pobj_c->ppobj_Member[i4]->GetName().c_str());330 lstrcpy(buffer+i2,member->GetName().c_str()); 331 331 i2+=lstrlen(buffer+i2)+1; 332 332 333 333 // 型 334 *(long *)(buffer+i2)= pobj_c->ppobj_Member[i4]->GetType().GetBasicType();334 *(long *)(buffer+i2)=member->GetType().GetBasicType(); 335 335 i2+=sizeof(long); 336 336 337 337 // 型の拡張情報 338 SetLpIndex_DebugFile(buffer,&i2, pobj_c->ppobj_Member[i4]->GetType());338 SetLpIndex_DebugFile(buffer,&i2,member->GetType()); 339 339 340 340 // アクセシビリティ 341 *(Prototype::Accessibility *)(buffer+i2)= pobj_c->ppobj_Member[i4]->GetAccessibility();341 *(Prototype::Accessibility *)(buffer+i2)=member->GetAccessibility(); 342 342 i2+=sizeof(Prototype::Accessibility); 343 343 344 memcpy(buffer+i2, pobj_c->ppobj_Member[i4]->SubScripts,sizeof(int)*MAX_ARRAYDIM);344 memcpy(buffer+i2,member->SubScripts,sizeof(int)*MAX_ARRAYDIM); 345 345 i2+=sizeof(int)*MAX_ARRAYDIM; 346 346 … … 705 705 i2+=sizeof(long); 706 706 707 //メンバ 708 pobj_c->iMemberNum=*(long *)(buffer+i2); 709 i2+=sizeof(long); 710 pobj_c->ppobj_Member= 711 (CMember **)HeapAlloc(hHeap,0,pobj_c->iMemberNum*sizeof(CMember *)); 712 for(i4=0;i4<pobj_c->iMemberNum;i4++){ 713 707 //静的メンバ 708 int nDynamicMember = *(long *)(buffer+i2); 709 i2+=sizeof(long); 710 for( i4=0; i4<nDynamicMember; i4++ ){ 714 711 // 名前 715 712 string name = (char *)(buffer+i2); … … 727 724 i2+=sizeof(Prototype::Accessibility); 728 725 729 pobj_c->ppobj_Member[i4]=new CMember( accessibility, name, type, false );730 731 memcpy( pobj_c->ppobj_Member[i4]->SubScripts,buffer+i2,sizeof(int)*MAX_ARRAYDIM);726 CMember *member=new CMember( accessibility, name, type, false ); 727 728 memcpy(member->SubScripts,buffer+i2,sizeof(int)*MAX_ARRAYDIM); 732 729 i2+=sizeof(int)*MAX_ARRAYDIM; 730 731 pobj_c->dynamicMembers.push_back( member ); 733 732 } 734 733 -
BasicCompiler_Common/ParamImpl.cpp
r116 r140 98 98 } 99 99 100 bool ParamImpl:: _overload_check( int level, const Parameters &targetParms, const Type &targetResultType ){100 bool ParamImpl::EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType ){ 101 101 //パラメータを識別してオーバーロードを解決 102 102 … … 153 153 return false; 154 154 } 155 if( argType.IsPointer() || param.IsPointer() ) 156 { 157 // ポインタ型の不整合は認めない 158 return false; 159 } 155 160 } 156 161 else if(level==OVERLOAD_LEVEL6){ … … 190 195 } 191 196 192 UserProc *ParamImpl::OverloadSolutionWithReturnType( const char *name, std::vector<UserProc *> &subs ){ 193 int sw=0; 194 UserProc *pUserProc = NULL; 195 196 for( int level=OVERLOAD_MIN_LEVEL; level<=OVERLOAD_MAX_LEVEL; level++ ){ 197 foreach( UserProc *pTempUserProc, subs ){ 198 199 //エラーチェック 200 if(_overload_check( level, pTempUserProc->Params(), pTempUserProc->ReturnType() )){ 201 if(sw){ 202 SetError(52,name,cp); 203 return 0; 204 } 205 sw=1; 206 207 pUserProc = pTempUserProc; 208 } 209 } 210 211 if( sw ) break; 212 } 213 214 if(!sw){ 215 SetError(52,name,cp); 216 return 0; 217 } 218 219 return pUserProc; 220 } 221 UserProc *ParamImpl::OverloadSolution( const char *name, std::vector<UserProc *> &subs ){ 197 UserProc *ParamImpl::_OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType ){ 222 198 int sw=0; 223 199 UserProc *pUserProc; … … 228 204 foreach( UserProc *pTempUserProc, subs ){ 229 205 230 //エラーチェック 231 if(_overload_check( level, pTempUserProc->Params(), Type() )){ 206 if(EvaluateOverloadScore( level, pTempUserProc->Params(), isEnabledReturnType?pTempUserProc->ReturnType():Type() )){ 207 trace( "レベル" << level << " ○適合..." << pTempUserProc->_paramStr ); 208 232 209 if(sw){ 233 return OverloadSolutionWithReturnType(name,subs); 210 if( isEnabledReturnType ){ 211 SetError(52,name,cp); 212 213 return 0; 214 } 215 else{ 216 // 戻り値も比較するモードにして再びオーバーロード解決を試みる 217 218 trace( "戻り値も比較するモードに切り替えてオーバーロード解決を試みる" ); 219 220 return OverloadSolution(name,subs, true); 221 } 234 222 } 235 223 sw=1; 236 224 237 225 pUserProc = pTempUserProc; 226 } 227 else 228 { 229 trace( "レベル" << level << " ×不適合..." << pTempUserProc->_paramStr ); 238 230 } 239 231 } … … 260 252 if(!sw){ 261 253 SetError(52,name,cp); 254 262 255 return 0; 263 256 } 264 257 258 265 259 return pUserProc; 260 } 261 UserProc *ParamImpl::OverloadSolution( const char *name, std::vector<UserProc *> &subs, bool isEnabledReturnType ){ 262 trace( "" ); 263 trace( "■■■■■■■■■■■■■■■■■■" ); 264 trace( "■■■ オーバーロード解決(" << name << ")" ); 265 266 UserProc *result = _OverloadSolution( name, subs, isEnabledReturnType ); 267 268 trace( "■■■ ここまで" ); 269 trace( "■■■■■■■■■■■■■■■■■■" ); 270 trace( "" ); 271 272 return result; 266 273 } 267 274 -
BasicCompiler_Common/Procedure.cpp
r135 r140 487 487 pGlobalProc->SetParamsAndReturnType( buffer + i, nowLine, true ); 488 488 489 #ifdef _DEBUG 489 490 490 pGlobalProc->_paramStr = buffer + i; 491 #endif 491 492 492 493 493 -
BasicCompiler_Common/Procedure.h
r116 r140 92 92 class UserProc : public Procedure 93 93 { 94 #ifdef _DEBUG95 94 public: 96 95 string _paramStr; 97 #endif98 96 99 97 private: -
BasicCompiler_Common/Subroutine.cpp
r135 r140 602 602 pUserProc->SetParamsAndReturnType( buffer + i, nowLine, isStatic ); 603 603 604 #ifdef _DEBUG605 604 pUserProc->_paramStr = buffer + i; 606 #endif607 605 608 606 -
BasicCompiler_Common/Type.cpp
r131 r140 490 490 491 491 if( !( index == 0 || index == -1 ) ){ 492 if( pClass->GetNamespaceScopes().size() >= 1 ) 493 { 494 return pClass->GetNamespaceScopes().ToString() + "." + pClass->GetName(); 495 } 492 496 return pClass->GetName(); 493 497 } -
BasicCompiler_Common/VarList.cpp
r137 r140 155 155 } 156 156 void VarList_Member(HWND hVarTree,HTREEITEM hParent,LONG_PTR pTopOffset,const CClass &objClass,BOOL bPtr){ 157 int i;158 157 char VarData[VN_SIZE],VarName[VN_SIZE]; 159 158 TV_INSERTSTRUCT tv; … … 165 164 tv.item.pszText=VarData; 166 165 167 for(i=0;i<objClass.iMemberNum;i++){166 BOOST_FOREACH( CMember *pMember, objClass.GetDynamicMembers() ){ 168 167 if(bPtr){ 169 168 lstrcpy(VarName,"->"); 170 lstrcat(VarName, objClass.ppobj_Member[i]->GetName().c_str());169 lstrcat(VarName,pMember->GetName().c_str()); 171 170 } 172 171 else{ 173 172 lstrcpy(VarName,"."); 174 lstrcat(VarName, objClass.ppobj_Member[i]->GetName().c_str());173 lstrcat(VarName,pMember->GetName().c_str()); 175 174 } 176 175 177 176 LONG_PTR offset; 178 177 int i2; 179 offset=objClass.GetMemberOffset( objClass.ppobj_Member[i]->GetName().c_str(), &i2 );180 181 if( objClass.ppobj_Member[i]->SubScripts[0]!=-1){178 offset=objClass.GetMemberOffset( pMember->GetName().c_str(), &i2 ); 179 180 if(pMember->SubScripts[0]!=-1){ 182 181 //構造体内の配列 183 182 sprintf(VarData,"%s %s(&H%X)",VarName,STRING_ARRAY,pTopOffset+offset); … … 188 187 VarList_Array(hVarTree,hParent, 189 188 pTopOffset+offset, 190 objClass.ppobj_Member[i]->GetType(),191 objClass.ppobj_Member[i]->SubScripts);189 pMember->GetType(), 190 pMember->SubScripts); 192 191 } 193 192 else{ … … 196 195 &tv, 197 196 VarName, 198 objClass.ppobj_Member[i]->GetType(),197 pMember->GetType(), 199 198 pTopOffset+offset); 200 199 } … … 323 322 } 324 323 void RefreshLocalVar(void){ 325 int i ,i2,i3,sw;324 int i2,i3,sw; 326 325 char temporary[VN_SIZE]; 327 326 TV_INSERTSTRUCT tv; … … 415 414 //Thisポインタを取得 416 415 LONG_PTR pThis; 417 const Variable *pVar = pUserProc->localVars.Find( "_System_LocalThis");416 const Variable *pVar = pUserProc->localVars.Find( Symbol( "_System_LocalThis" ) ); 418 417 if( !pVar ){ 419 418 return; … … 422 421 ReadProcessMemory(hDebugProcess,(void *)lpData,&pThis,sizeof(LONG_PTR),&accessBytes); 423 422 424 for(i=0;i<pUserProc->GetParentClassPtr()->iMemberNum;i++){425 offset=pUserProc->GetParentClassPtr()->GetMemberOffset( p UserProc->GetParentClassPtr()->ppobj_Member[i]->GetName().c_str(),&i2);426 427 if(p UserProc->GetParentClassPtr()->ppobj_Member[i]->SubScripts[0]!=-1){423 BOOST_FOREACH( CMember *pMember, pUserProc->GetParentClassPtr()->GetDynamicMembers() ){ 424 offset=pUserProc->GetParentClassPtr()->GetMemberOffset( pMember->GetName().c_str(),&i2); 425 426 if(pMember->SubScripts[0]!=-1){ 428 427 //配列 429 428 sprintf(temporary,"%s %s(&H%X)", 430 p UserProc->GetParentClassPtr()->ppobj_Member[i]->GetName().c_str(),429 pMember->GetName().c_str(), 431 430 STRING_ARRAY, 432 431 (ULONG_PTR)offset); … … 437 436 VarList_Array(hVarTree_This,hParent, 438 437 pThis+offset, 439 p UserProc->GetParentClassPtr()->ppobj_Member[i]->GetType(),440 p UserProc->GetParentClassPtr()->ppobj_Member[i]->SubScripts);438 pMember->GetType(), 439 pMember->SubScripts); 441 440 } 442 441 else{ 443 442 VarList_Insert(hVarTree_This,&tv, 444 p UserProc->GetParentClassPtr()->ppobj_Member[i]->GetName().c_str(),445 p UserProc->GetParentClassPtr()->ppobj_Member[i]->GetType(),443 pMember->GetName().c_str(), 444 pMember->GetType(), 446 445 pThis+offset); 447 446 } -
BasicCompiler_Common/Variable.cpp
r103 r140 1 1 #include "common.h" 2 2 3 bool Variable::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name) const3 bool Variable::IsEqualSymbol( const Symbol &symbol, bool isSupportStaticMember ) const 4 4 { 5 if( GetName() != name ){ 6 return false; 7 } 8 return NamespaceScopes::IsSameArea( this->namespaceScopes, namespaceScopes ); 9 } 10 bool Variable::IsEqualSymbol( const string &fullName ) const 11 { 12 char AreaName[VN_SIZE] = ""; //オブジェクト変数 13 char NestName[VN_SIZE] = ""; //入れ子メンバ 14 bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName ); 15 16 if( IsEqualSymbol( NamespaceScopes( AreaName ), NestName ) ){ 5 if( GetName() == symbol.GetName() 6 && NamespaceScopes::IsSameArea( this->namespaceScopes, symbol.GetNamespaceScopes() ) ) 7 { 17 8 return true; 18 9 } 19 10 20 if( isNest ){ 11 if( isSupportStaticMember && symbol.GetNamespaceScopes().size() >= 1 ) 12 { 21 13 // 静的メンバを考慮 14 NamespaceScopes namespaceScopes( symbol.GetNamespaceScopes() ); 15 string name = namespaceScopes[namespaceScopes.size()-1] + "." + symbol.GetName(); 16 namespaceScopes.pop_back(); 22 17 23 char AreaName2[VN_SIZE] = ""; //オブジェクト変数 24 char NestName2[VN_SIZE] = ""; //入れ子メンバ 25 bool isNest = SplitMemberName( AreaName, AreaName2, NestName2 ); 26 lstrcat( NestName2, "." ); 27 lstrcat( NestName2, NestName ); 28 29 return IsEqualSymbol( NamespaceScopes( AreaName2 ), NestName2 ); 18 return IsEqualSymbol( Symbol( namespaceScopes, name ), false ); 30 19 } 31 32 20 return false; 33 21 } -
BasicCompiler_Common/Variable.h
r103 r140 2 2 3 3 #include "Type.h" 4 #include <Symbol.h> 4 5 5 6 class Variable : public Type … … 61 62 } 62 63 63 bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const; 64 bool IsEqualSymbol( const string &name ) const; 64 bool IsEqualSymbol( const Symbol &symbol, bool isSupportStaticMember = true ) const; 65 65 66 66 void ConstOff(){ … … 157 157 } 158 158 159 bool DuplicateCheck( const string &varName) const159 bool DuplicateCheck( const Symbol &symbol ) const 160 160 { 161 161 //レキシカルスコープを考慮して重複判定 … … 165 165 && var.ScopeLevel == obj_LexScopes.GetNowLevel() //現在のスコープと同一レベル 166 166 ){ 167 if( var.IsEqualSymbol( varName) ){167 if( var.IsEqualSymbol( symbol ) ){ 168 168 return true; 169 169 } … … 173 173 } 174 174 175 const Variable *BackSearch( const string &varName) const175 const Variable *BackSearch( const Symbol &symbol ) const 176 176 { 177 177 //レキシカルスコープを考慮してバックサーチ … … 181 181 && var.ScopeLevel <= obj_LexScopes.GetNowLevel() //現在のスコープレベルを超さないもの(Returnによる解放処理中を考慮) 182 182 ){ 183 if( var.IsEqualSymbol( varName) ){183 if( var.IsEqualSymbol( symbol ) ){ 184 184 return &var; 185 185 } … … 189 189 } 190 190 191 const Variable *Find( const string &varName)const191 const Variable *Find( const Symbol &symbol )const 192 192 { 193 193 int max = (int)this->size(); 194 194 for( int i=0; i<max; i++ ){ 195 195 Variable *pVar = (*this)[i]; 196 if( pVar->IsEqualSymbol( varName) ){196 if( pVar->IsEqualSymbol( symbol ) ){ 197 197 return pVar; 198 198 } … … 205 205 206 206 207 -
BasicCompiler_Common/VariableOpe.cpp
r138 r140 547 547 bool GetMemberType( const CClass &objClass, const char *lpszMember, Type &resultType, BOOL bPrivateAccess, bool isErrorEnabled){ 548 548 extern int cp; 549 int i;550 549 551 550 //クラス、配列の構成要素を解析する … … 558 557 if(!GetVarFormatString(VarName,array,lpPtrOffset,NestMember,refType)) return false; 559 558 560 for(i=0;i<objClass.iMemberNum;i++){ 561 if( objClass.ppobj_Member[i]->GetName() == VarName ){ 559 bool isFound = false; 560 CMember *pMember = NULL; 561 BOOST_FOREACH( pMember, objClass.GetDynamicMembers() ){ 562 if( pMember->GetName() == VarName ){ 563 isFound = true; 562 564 break; 563 565 } 564 566 } 565 if( i==objClass.iMemberNum){567 if( !isFound ){ 566 568 if(isErrorEnabled) SetError(103,VarName,cp); 567 569 return false; … … 571 573 if( &objClass == pobj_CompilingClass ){ 572 574 //同一クラスオブジェクトの場合はプライベートアクセスを容認する 573 if( objClass.ppobj_Member[i]->IsNoneAccess() ){575 if( pMember->IsNoneAccess() ){ 574 576 if(isErrorEnabled) SetError(107,VarName,cp); 575 577 return false; … … 577 579 } 578 580 else{ 579 if(( bPrivateAccess==0 && objClass.ppobj_Member[i]->IsPrivate() )||580 objClass.ppobj_Member[i]->IsNoneAccess() ){581 if(( bPrivateAccess==0 && pMember->IsPrivate() )|| 582 pMember->IsNoneAccess() ){ 581 583 if(isErrorEnabled) SetError(107,VarName,cp); 582 584 return false; 583 585 } 584 else if( bPrivateAccess==0 && objClass.ppobj_Member[i]->IsProtected() ){586 else if( bPrivateAccess==0 && pMember->IsProtected() ){ 585 587 if(isErrorEnabled) SetError(108,VarName,cp); 586 588 return false; … … 588 590 } 589 591 590 resultType = objClass.ppobj_Member[i]->GetType();592 resultType = pMember->GetType(); 591 593 592 594 //ポインタ変数の場合 593 595 if( resultType.IsPointer() ){ 594 if( objClass.ppobj_Member[i]->SubScripts[0]==-1){596 if(pMember->SubScripts[0]==-1){ 595 597 lstrcpy(lpPtrOffset,array); 596 598 array[0]=0; … … 607 609 //入れ子構造の場合 608 610 609 return GetMemberType( objClass.ppobj_Member[i]->GetType().GetClass(),611 return GetMemberType( pMember->GetType().GetClass(), 610 612 NestMember, 611 613 resultType, … … 614 616 } 615 617 616 if(array[0]==0&& objClass.ppobj_Member[i]->SubScripts[0]!=-1){618 if(array[0]==0&&pMember->SubScripts[0]!=-1){ 617 619 resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR ); 618 620 return true; … … 633 635 } 634 636 bool GetVarType( const char *nameBuffer, Type &resultType, bool isErrorEnabled){ 635 int i;636 637 char variable[VN_SIZE]; 637 638 … … 668 669 ///////////////// 669 670 670 pVar = UserProc::CompilingUserProc().localVars.BackSearch( VarName);671 pVar = UserProc::CompilingUserProc().localVars.BackSearch( Symbol( VarName ) ); 671 672 if( pVar ){ 672 673 goto ok; … … 693 694 //クラス内メンバを参照するとき(通常) 694 695 695 for(i=0;i<pobj_CompilingClass->iMemberNum;i++){ 696 if( pobj_CompilingClass->ppobj_Member[i]->GetName() == VarName ){ 696 bool isFound = false; 697 BOOST_FOREACH( CMember *pMember, pobj_CompilingClass->GetDynamicMembers() ){ 698 if( pMember->GetName() == VarName ){ 699 isFound = true; 697 700 break; 698 701 } 699 702 } 700 if( i==pobj_CompilingClass->iMemberNum) goto NonClassMember;703 if( !isFound ) goto NonClassMember; 701 704 } 702 705 … … 715 718 GetNowStaticVarFullName(VarName,temporary); 716 719 717 pVar = globalVars.Find( temporary);720 pVar = globalVars.Find( Symbol( temporary ) ); 718 721 if( pVar ){ 719 722 goto ok; … … 744 747 sprintf(temp2,"%s.%s",VarName,temporary); 745 748 746 pVar = globalVars.Find( temp2);749 pVar = globalVars.Find( Symbol( temp2 ) ); 747 750 if( pVar ){ 748 751 lstrcpy(member,tempMember); … … 757 760 sprintf(temp2,"%s.%s",pobj_CompilingClass->GetName().c_str(),VarName); 758 761 759 pVar = globalVars.Find( temp2);762 pVar = globalVars.Find( Symbol( temp2 ) ); 760 763 if( pVar ){ 761 764 goto ok; … … 768 771 //////////////////// 769 772 770 pVar = globalVars.BackSearch( VarName);773 pVar = globalVars.BackSearch( Symbol( VarName ) ); 771 774 if( pVar ){ 772 775 goto ok; … … 1041 1044 extern int AllGlobalVarSize; 1042 1045 1043 if( globalVars.DuplicateCheck( name) ){1046 if( globalVars.DuplicateCheck( Symbol( name ) ) ){ 1044 1047 //2重定義のエラー 1045 1048 SetError(15,name,cp); -
BasicCompiler_Common/WatchList.cpp
r137 r140 104 104 105 105 int Debugging_GetMember( const CClass &objClass,char *member,RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess){ 106 int i ,i2;106 int i2; 107 107 108 108 //直接参照に切り替え … … 124 124 //////////////////////////// 125 125 126 int offset = objClass.GetMemberOffset( VarName, &i ); 127 if(i==objClass.iMemberNum) return 0; 126 int memberIndex; 127 int offset = objClass.GetMemberOffset( VarName, &memberIndex ); 128 if(memberIndex==objClass.GetDynamicMembers().size()) return 0; 129 130 CMember *pMember = objClass.GetDynamicMembers()[memberIndex]; 128 131 129 132 130 133 //アクセシビリティをチェック 131 if(( bPrivateAccess==0 && objClass.ppobj_Member[i]->IsPrivate() )||132 objClass.ppobj_Member[i]->IsNoneAccess() ){134 if(( bPrivateAccess==0 && pMember->IsPrivate() )|| 135 pMember->IsNoneAccess() ){ 133 136 return 0; 134 137 } 135 else if(bPrivateAccess==0&& objClass.ppobj_Member[i]->IsProtected())138 else if(bPrivateAccess==0&&pMember->IsProtected()) 136 139 return 0; 137 140 138 resultType = objClass.ppobj_Member[i]->GetType();141 resultType = pMember->GetType(); 139 142 140 143 //ポインタ変数の場合 141 144 if( resultType.IsPointer() ){ 142 if( objClass.ppobj_Member[i]->SubScripts[0]==-1){145 if(pMember->SubScripts[0]==-1){ 143 146 lstrcpy(lpPtrOffset,array); 144 147 array[0]=0; … … 154 157 //配列オフセット 155 158 i2=Debugging_GetArray( 156 objClass.ppobj_Member[i]->SubScripts,159 pMember->SubScripts, 157 160 array, 158 161 resultType, … … 167 170 } 168 171 } 169 else if( objClass.ppobj_Member[i]->SubScripts[0]!=-1){172 else if(pMember->SubScripts[0]!=-1){ 170 173 resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR ); 171 174 } … … 209 212 } 210 213 211 i2=Debugging_GetMember( objClass.ppobj_Member[i]->GetType().GetClass(),214 i2=Debugging_GetMember(pMember->GetType().GetClass(), 212 215 NestMember, 213 216 pRelativeVar, … … 322 325 int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, int *pss){ 323 326 extern HANDLE hDebugProcess; 324 int i ,i2,i3;327 int i2,i3; 325 328 char member[VN_SIZE],VarName[VN_SIZE],array[VN_SIZE],lpPtrOffset[VN_SIZE]; 326 329 LONG_PTR lpData; … … 339 342 ///////////////// 340 343 if( UserProc::IsLocalAreaCompiling() ){ 341 const Variable *pVar = UserProc::CompilingUserProc().localVars.Find( VarName);344 const Variable *pVar = UserProc::CompilingUserProc().localVars.Find( Symbol( VarName ) ); 342 345 343 346 if( pVar ){ … … 379 382 //クラス内メンバを参照するとき(通常) 380 383 381 for(i=0;i<pobj_CompilingClass->iMemberNum;i++){ 382 if( pobj_CompilingClass->ppobj_Member[i]->GetName() == VarName ){ 384 bool isFound = false; 385 BOOST_FOREACH( CMember *pMember, pobj_CompilingClass->GetDynamicMembers() ){ 386 if( pMember->GetName() == VarName ){ 387 isFound = true; 383 388 break; 384 389 } 385 390 } 386 if( i==pobj_CompilingClass->iMemberNum) goto NonClassMember;391 if( !isFound ) goto NonClassMember; 387 392 } 388 393 -
BasicCompiler_Common/common.h
r135 r140 47 47 48 48 #ifdef _AMD64_ 49 #define VER_INFO "(x64) CP4(rev.265)"49 #define VER_INFO "(x64) (rev.275)" 50 50 #else 51 #define VER_INFO " CP4(rev.265)"51 #define VER_INFO "(rev.275)" 52 52 #endif 53 53 … … 153 153 #define EXE_HEADER_SIZE 0x1000 154 154 155 156 // ログ生成を行うためのクラス 157 #include <logger.h> 155 158 156 159 // クラス管理用のクラス -
BasicCompiler_Common/error.cpp
r131 r140 344 344 SendDlgItemMessage(hMainDlg,IDC_ERRORLIST,EM_REPLACESEL,0,(LPARAM)temp2); 345 345 346 346 347 if(num==-2){ 347 348 //コンパイルメッセージ … … 355 356 extern BOOL bError; 356 357 bError=1; 358 359 // ログに出力 360 trace( "error - " << temp2 ); 357 361 } 358 362 else{ 359 363 extern int WarningNum; 360 364 WarningNum++; 365 366 // ログに出力 367 trace( "warning - " << temp2 ); 361 368 } 362 369 } -
BasicCompiler_Common/include/Member.h
r138 r140 63 63 static void InitStaticMember(void); 64 64 }; 65 typedef std::vector<CMember *> Members; -
BasicCompiler_Common/src/Namespace.cpp
r107 r140 3 3 4 4 NamespaceScopes::NamespaceScopes( const string &namespaceStr ){ 5 int i = 0; 6 while( i < (int)namespaceStr.size() ){ 7 char temporary[VN_SIZE]; 8 for( int i2=0; ; i2++, i++ ){ 9 if( namespaceStr[i] == '.' || namespaceStr[i] == '\0' ){ 10 temporary[i2] = 0; 11 break; 12 } 13 temporary[i2] = namespaceStr[i]; 5 if( namespaceStr.size() == 0 ){ 6 return; 7 } 8 9 string::size_type i = 0; 10 while( true ){ 11 string::size_type i2 = namespaceStr.find( '.', i ); 12 13 string tempName = namespaceStr.substr( i, i2-i ); 14 15 push_back( tempName ); 16 17 if( i2 == string::npos ){ 18 break; 14 19 } 15 push_back( temporary );16 20 17 if( namespaceStr[i] == '.' ){ 18 i++; 19 } 21 i = i2 + 1; 20 22 } 21 23 }
Note:
See TracChangeset
for help on using the changeset viewer.