Changeset 100 in dev
- Timestamp:
- Apr 24, 2007, 3:17:29 AM (18 years ago)
- Files:
-
- 1 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler32/BasicCompiler.vcproj
r91 r100 1938 1938 Name="Meta Parts" 1939 1939 > 1940 <File 1941 RelativePath="..\BasicCompiler_Common\include\Namespace.h" 1942 > 1943 </File> 1940 1944 <File 1941 1945 RelativePath="..\BasicCompiler_Common\Parameter.h" -
BasicCompiler32/Compile_ProcOp.cpp
r95 r100 229 229 extern char *basbuf; 230 230 extern HANDLE hHeap; 231 extern UserProc **ppSubHash;231 extern GlobalProc **ppSubHash; 232 232 extern BOOL bDebugCompile; 233 233 int i3,i4,LocalVarSchedule,EspOffsetSchedule,BaseOffset; … … 865 865 } 866 866 void CompileLocal(){ 867 extern UserProc **ppSubHash;867 extern GlobalProc **ppSubHash; 868 868 int i2; 869 UserProc *pUserProc;870 869 871 870 extern BOOL bDll; 872 871 if(bDll){ 873 872 //DLLの場合はグローバル変数を初期化するための関数を一番初めにコンパイルする 874 pUserProc=GetSubHash("_System_InitDllGlobalVariables");873 UserProc *pUserProc=GetSubHash("_System_InitDllGlobalVariables"); 875 874 if(pUserProc){ 876 875 CompileBufferInProcedure( *pUserProc ); … … 893 892 894 893 repeat: 894 GlobalProc *pGlobalProc; 895 895 for(i2=0;i2<MAX_HASH;i2++){ 896 p UserProc=ppSubHash[i2];897 while(p UserProc){898 CompileBufferInProcedure( *p UserProc );899 p UserProc=pUserProc->pNextData;896 pGlobalProc=ppSubHash[i2]; 897 while(pGlobalProc){ 898 CompileBufferInProcedure( *pGlobalProc ); 899 pGlobalProc=pGlobalProc->pNextData; 900 900 } 901 901 } … … 913 913 //プロシージャコンパイルによって、プロシージャコンパイルが必要になる場合 914 914 for(i2=0;i2<MAX_HASH;i2++){ 915 p UserProc=ppSubHash[i2];916 while(p UserProc){917 CompileBufferInProcedure( *p UserProc );918 p UserProc=pUserProc->pNextData;915 pGlobalProc=ppSubHash[i2]; 916 while(pGlobalProc){ 917 CompileBufferInProcedure( *pGlobalProc ); 918 pGlobalProc=pGlobalProc->pNextData; 919 919 } 920 920 } -
BasicCompiler32/MakePeHdr.cpp
r95 r100 558 558 ExportNamesLength=lstrlen(lpExportNames)+1; 559 559 560 extern UserProc **ppSubHash;561 UserProc *pUserProc,*psi2;560 extern GlobalProc **ppSubHash; 561 GlobalProc *pUserProc,*psi2; 562 562 while(1){ 563 563 //辞書順にサーチ -
BasicCompiler64/BasicCompiler.vcproj
r97 r100 577 577 Name="Meta Parts" 578 578 > 579 <File 580 RelativePath="..\BasicCompiler_Common\include\Namespace.h" 581 > 582 </File> 579 583 <File 580 584 RelativePath="..\BasicCompiler_Common\Parameter.h" -
BasicCompiler64/Compile_ProcOp.cpp
r95 r100 219 219 extern char *basbuf; 220 220 extern HANDLE hHeap; 221 extern UserProc **ppSubHash;221 extern GlobalProc **ppSubHash; 222 222 extern BOOL bDebugCompile; 223 223 int i3,i4; … … 830 830 temporary[0]=0; 831 831 lstrcat( temporary, "------------------------------------------------------------------\n" ); 832 sprintf( temporary + lstrlen(temporary), "【 %s のコード情報】\n", userProc.Get FullName().c_str() );832 sprintf( temporary + lstrlen(temporary), "【 %s のコード情報】\n", userProc.GetName().c_str() ); 833 833 sprintf( temporary + lstrlen(temporary), "code size: %d bytes\n", userProc.GetCodeSize() ); 834 834 lstrcat( temporary, "------------------------------------------------------------------\n" ); … … 837 837 } 838 838 void CompileLocal(){ 839 extern UserProc **ppSubHash;839 extern GlobalProc **ppSubHash; 840 840 int i2; 841 UserProc *pUserProc;842 841 843 842 extern BOOL bDll; 844 843 if(bDll){ 845 844 //DLLの場合はグローバル変数を初期化するための関数を一番初めにコンパイルする 846 pUserProc=GetSubHash("_System_InitDllGlobalVariables");845 UserProc *pUserProc=GetSubHash("_System_InitDllGlobalVariables"); 847 846 if(pUserProc){ 848 847 CompileBufferInProcedure( *pUserProc ); … … 865 864 866 865 repeat: 866 GlobalProc *pGlobalProc; 867 867 for(i2=0;i2<MAX_HASH;i2++){ 868 p UserProc=ppSubHash[i2];869 while(p UserProc){870 CompileBufferInProcedure( *p UserProc );871 p UserProc=pUserProc->pNextData;868 pGlobalProc=ppSubHash[i2]; 869 while(pGlobalProc){ 870 CompileBufferInProcedure( *pGlobalProc ); 871 pGlobalProc=pGlobalProc->pNextData; 872 872 } 873 873 } … … 885 885 //プロシージャコンパイルによって、プロシージャコンパイルが必要になる場合 886 886 for(i2=0;i2<MAX_HASH;i2++){ 887 p UserProc=ppSubHash[i2];888 while(p UserProc){889 CompileBufferInProcedure( *p UserProc );890 p UserProc=pUserProc->pNextData;887 pGlobalProc=ppSubHash[i2]; 888 while(pGlobalProc){ 889 CompileBufferInProcedure( *pGlobalProc ); 890 pGlobalProc=pGlobalProc->pNextData; 891 891 } 892 892 } -
BasicCompiler64/MakePeHdr.cpp
r95 r100 531 531 ExportNamesLength=lstrlen(lpExportNames)+1; 532 532 533 extern UserProc **ppSubHash;534 UserProc *pUserProc,*psi2;533 extern GlobalProc **ppSubHash; 534 GlobalProc *pUserProc,*psi2; 535 535 while(1){ 536 536 //辞書順にサーチ -
BasicCompiler_Common/BasicCompiler.h
r97 r100 23 23 DWORD ImageBase; 24 24 INCLUDEFILEINFO IncludeFileInfo; 25 UserProc **ppSubHash;25 GlobalProc **ppSubHash; 26 26 int SubNum; 27 27 char **ppMacroNames; -
BasicCompiler_Common/Class.cpp
r97 r100 118 118 119 119 120 CMethod::CMethod(CMethod *pobj){ 121 //コピーコンストラクタ 122 memset(this,0,sizeof(CMethod)); 123 124 pUserProc=pobj->pUserProc; 125 126 bAbstract=pobj->bAbstract; 127 128 bVirtual=pobj->bVirtual; 129 } 130 CMethod::CMethod(){ 131 memset(this,0,sizeof(CMethod)); 120 //コピーコンストラクタ 121 CMethod::CMethod(CMethod *pMethod) 122 : pUserProc( pMethod->pUserProc ) 123 , dwAccess( pMethod->dwAccess ) 124 , bAbstract( pMethod->bAbstract ) 125 , bVirtual( pMethod->bVirtual ) 126 , isConst( pMethod->isConst ) 127 , isStatic( pMethod->isStatic ) 128 { 129 } 130 131 CMethod::CMethod( UserProc *pUserProc, DWORD dwAccess, BOOL bAbstract, BOOL bVirtual, bool isConst, bool isStatic ) 132 : pUserProc( pUserProc ) 133 , dwAccess( dwAccess ) 134 , bAbstract( bAbstract ) 135 , bVirtual( bVirtual ) 136 , isConst( isConst ) 137 , isStatic( isStatic ) 138 , pobj_InheritsClass( NULL ) 139 { 132 140 } 133 141 CMethod::~CMethod(){ … … 330 338 } 331 339 void CClass::AddMethod( UserProc *pUserProc,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual ){ 332 CMethod *method = new CMethod(); 333 method->pUserProc = pUserProc; 334 method->dwAccess = dwAccess; 335 method->isConst = isConst; 336 method->bAbstract = bAbstract; 337 method->bVirtual = bVirtual; 338 method->pobj_InheritsClass = 0; 340 CMethod *method = new CMethod( pUserProc, dwAccess, bAbstract, bVirtual, isConst, false ); 339 341 340 342 methods.push_back( method ); … … 344 346 } 345 347 void CClass::AddStaticMethod(UserProc *pUserProc,DWORD dwAccess){ 346 CMethod *method = new CMethod(); 347 method->pUserProc=pUserProc; 348 method->dwAccess=dwAccess; 349 method->bAbstract=0; 350 method->bVirtual=0; 351 method->pobj_InheritsClass=0; 348 CMethod *method = new CMethod( pUserProc, dwAccess, FALSE, FALSE, false, true ); 352 349 353 350 staticMethods.push_back( method ); … … 421 418 } 422 419 423 void CClass::EnumStaticMethod( const char *methodName, std::vector<UserProc *> &subs ) const420 void CClass::EnumStaticMethod( const char *methodName, vector<UserProc *> &subs ) const 424 421 { 425 422 foreach( CMethod *method, staticMethods ){ … … 430 427 } 431 428 432 void CClass::EnumMethod( const char *methodName, std::vector<UserProc *> &subs ) const429 void CClass::EnumMethod( const char *methodName, vector<UserProc *> &subs ) const 433 430 { 434 431 //オブジェクトのメンバ関数の場合 … … 441 438 } 442 439 443 void CClass::EnumMethod( const BYTE idOperatorCalc, std::vector<UserProc *> &subs ) const440 void CClass::EnumMethod( const BYTE idOperatorCalc, vector<UserProc *> &subs ) const 444 441 { 445 442 //オブジェクトのメンバ関数の場合 … … 603 600 604 601 UserProc **ppsi; 605 ppsi=(UserProc **)HeapAlloc(hHeap,0,vtbl_num*sizeof( UserProc *));602 ppsi=(UserProc **)HeapAlloc(hHeap,0,vtbl_num*sizeof(GlobalProc *)); 606 603 607 604 //関数テーブルに値をセット … … 642 639 int i; 643 640 for(i=0;i<vtbl_num;i++){ 644 UserProc *pUserProc;645 pUserProc=( UserProc *)pVtbl[i];641 GlobalProc *pUserProc; 642 pUserProc=(GlobalProc *)pVtbl[i]; 646 643 if(!pUserProc) continue; 647 644 pVtbl[i]=pUserProc->beginOpAddress+ImageBase+MemPos_CodeSection; … … 803 800 } 804 801 } 805 return 0;802 return NULL; 806 803 } 807 804 … … 932 929 933 930 //関数ハッシュへ登録 934 UserProc *pUserProc;935 pUserProc=AddSubData( buffer,nowLine,bVirtual,pobj_c, (bStatic!=0) );931 GlobalProc *pUserProc; 932 pUserProc=AddSubData( NamespaceScopes(), buffer,nowLine,bVirtual,pobj_c, (bStatic!=0) ); 936 933 if(!pUserProc) return; 937 934 -
BasicCompiler_Common/Class.h
r97 r100 3 3 #include <vector> 4 4 #include "Type.h" 5 #include "Procedure.h" 5 6 6 7 class CClass; 7 class UserProc;8 8 9 9 #define ACCESS_NON 0 … … 37 37 static void InitStaticMember(void); 38 38 }; 39 class CMethod{ 39 class CMethod 40 { 40 41 public: 41 42 UserProc *pUserProc; 43 42 44 DWORD dwAccess; 43 45 BOOL bAbstract; 44 46 BOOL bVirtual; 45 47 bool isConst; 48 bool isStatic; 46 49 47 50 CClass *pobj_InheritsClass; 48 51 49 52 CMethod(CMethod *pobj); 50 CMethod( );53 CMethod( UserProc *pUserProc, DWORD dwAccess, BOOL bAbstract, BOOL bVirtual, bool isConst, bool isStatic ); 51 54 ~CMethod(); 52 55 }; 56 53 57 class CDBClass; 54 58 class CDebugSection; … … 135 139 136 140 //メソッドを列挙 137 void EnumStaticMethod( const char *methodName, std::vector<UserProc *> &subs ) const;138 void EnumMethod( const char *methodName, std::vector<UserProc *> &subs ) const;139 void EnumMethod( const BYTE idOperatorCalc, std::vector<UserProc *> &subs ) const;141 void EnumStaticMethod( const char *methodName, vector<UserProc *> &subs ) const; 142 void EnumMethod( const char *methodName, vector<UserProc *> &subs ) const; 143 void EnumMethod( const BYTE idOperatorCalc, vector<UserProc *> &subs ) const; 140 144 const std::vector<CMethod *> &GetMethods() const 141 145 { -
BasicCompiler_Common/Debug.cpp
r75 r100 224 224 SendDlgItemMessage(hMainDlg,IDC_DEBUGLIST,EM_REPLACESEL,0,(LPARAM)buffer); 225 225 } 226 UserProc *GetSubFromObp(ULONG_PTR pos){227 extern UserProc **ppSubHash;228 UserProc *pUserProc;226 GlobalProc *GetSubFromObp(ULONG_PTR pos){ 227 extern GlobalProc **ppSubHash; 228 GlobalProc *pUserProc; 229 229 int i2; 230 230 … … 447 447 pobj_dti=new CDebugThreadInfo(); 448 448 449 UserProc *pUserProc;449 GlobalProc *pUserProc; 450 450 451 451 extern DWORD dwStepRun; -
BasicCompiler_Common/DebugMiddleFile.cpp
r88 r100 205 205 206 206 //プロシージャ情報 207 extern UserProc **ppSubHash;207 extern GlobalProc **ppSubHash; 208 208 extern int SubNum; 209 UserProc *pUserProc;209 GlobalProc *pUserProc; 210 210 *(long *)(buffer+i2)=SubNum; 211 211 i2+=sizeof(long); … … 574 574 575 575 //プロシージャ情報 576 UserProc *pUserProc;576 GlobalProc *pUserProc; 577 577 SubNum=*(long *)(buffer+i2); 578 578 i2+=sizeof(long); 579 ppSubHash=( UserProc **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(UserProc *));579 ppSubHash=(GlobalProc **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(GlobalProc *)); 580 580 for(int i6=0;i6<SubNum;i6++){ 581 581 char szParentClassName[VN_SIZE]; … … 596 596 597 597 // オブジェクトを生成 598 pUserProc = new UserProc( name, UserProc::Function, false, false, false ); 598 // TODO: 名前空間が未完成 599 pUserProc = new GlobalProc( NamespaceScopes(), name, Procedure::Function, false, false, false ); 599 600 pUserProc->pNextData=0; 600 601 pUserProc->id=id; … … 664 665 i4=hash_default(pUserProc->GetName().c_str()); 665 666 666 UserProc *psi2;667 GlobalProc *psi2; 667 668 if(ppSubHash[i4]){ 668 669 psi2=ppSubHash[i4]; … … 730 731 i2+=sizeof(long); 731 732 for( i4=0; i4<nMethod; i4++ ){ 732 CMethod *method = new CMethod(); 733 734 method->dwAccess=*(long *)(buffer+i2); 733 734 DWORD dwAccess=*(long *)(buffer+i2); 735 735 i2+=sizeof(long); 736 736 … … 739 739 i2+=lstrlen(buffer+i2)+1; 740 740 741 if(szInherits[0]) 742 method->pobj_InheritsClass=pobj_DBClass->check(szInherits); 743 else method->pobj_InheritsClass=0; 741 CClass *pobj_InheritsClass = NULL; 742 if(szInherits[0]){ 743 pobj_InheritsClass=pobj_DBClass->check(szInherits); 744 } 744 745 745 746 lstrcpy(temp2,buffer+i2); … … 747 748 748 749 CClass *pobj_temp_c; 749 pobj_temp_c= method->pobj_InheritsClass;750 pobj_temp_c=pobj_InheritsClass; 750 751 if(pobj_temp_c==0) pobj_temp_c=pobj_c; 751 752 i5=hash_default(temp2); … … 755 756 pUserProc=pUserProc->pNextData; 756 757 } 757 method->pUserProc=pUserProc; 758 759 CMethod *method = new CMethod( pUserProc, dwAccess, 0,0,false, false); 760 method->pobj_InheritsClass = pobj_InheritsClass; 758 761 759 762 pobj_c->methods.push_back( method ); … … 795 798 796 799 797 extern UserProc **ppSubHash;800 extern GlobalProc **ppSubHash; 798 801 ppSubHash=this->ppSubHash; 799 802 pSub_DebugSys_EndProc=GetSubHash("_DebugSys_EndProc"); … … 951 954 extern char **ppMacroNames; 952 955 ppMacroNames=0; 953 extern UserProc **ppSubHash;956 extern GlobalProc **ppSubHash; 954 957 extern int SubNum; 955 958 ppSubHash=this->ppSubHash; -
BasicCompiler_Common/DebugSection.h
r88 r100 41 41 42 42 //プロシージャ 43 UserProc **ppSubHash;43 GlobalProc **ppSubHash; 44 44 int SubNum; 45 45 -
BasicCompiler_Common/Diagnose.cpp
r92 r100 34 34 int codeSizeOfClassMethod = 0; 35 35 for(int i2=0;i2<MAX_HASH;i2++){ 36 extern UserProc **ppSubHash;37 UserProc *pUserProc = ppSubHash[i2];36 extern GlobalProc **ppSubHash; 37 GlobalProc *pUserProc = ppSubHash[i2]; 38 38 while(pUserProc){ 39 39 if( pUserProc->IsCompiled() ){ -
BasicCompiler_Common/Intermediate_Step2.cpp
r92 r100 432 432 case ESC_MACRO: 433 433 case ESC_STATIC: 434 case ESC_NAMESPACE: 434 435 KillStringSpaces(Command+2); 435 436 break; -
BasicCompiler_Common/MakeExe.cpp
r96 r100 197 197 198 198 //サブルーチン(ユーザー定義)情報のメモリ解放 199 extern UserProc **ppSubHash;199 extern GlobalProc **ppSubHash; 200 200 extern char **ppMacroNames; 201 201 extern int MacroNum; -
BasicCompiler_Common/ParamImpl.cpp
r90 r100 8 8 9 9 #define OVERLOAD_MIN_LEVEL 0 10 #define OVERLOAD_MAX_LEVEL 410 #define OVERLOAD_MAX_LEVEL 5 11 11 #define OVERLOAD_LEVEL0 0 // 型調整なし。厳密に等しい 12 12 #define OVERLOAD_LEVEL1 1 // 型調整なし。レベル1以上はオブジェクトの場合は派生関係を考慮 -
BasicCompiler_Common/Procedure.cpp
r79 r100 1 1 #include "common.h" 2 2 3 string UserProc::GetFullName() const 4 { 5 if( HasParentClass() ){ 6 return (string)GetParentClass().name + "." + GetName(); 7 } 8 9 return GetName(); 10 } 3 11 bool UserProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic ){ 4 12 int i = 0; … … 355 363 return true; 356 364 } 365 bool UserProc::IsVirtual() const 366 { 367 if( pMethod == NULL ){ 368 return false; 369 } 370 return ( pMethod->bVirtual != 0 ); 371 } 372 bool UserProc::EqualName( const string &name ) const 373 { 374 SetError(); 375 return true; 376 } 377 378 GlobalProc *GlobalProc::Create( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine ){ 379 int i2; 380 char temporary[8192]; 381 382 int i=1; 383 384 Procedure::Kind kind = Procedure::Sub; 385 bool isMacro = false; 386 if(buffer[i]==ESC_FUNCTION) kind = Procedure::Function; 387 if(buffer[i]==ESC_MACRO){ 388 isMacro = true; 389 } 390 391 i++; 392 393 bool isCdecl = false; 394 bool isExport = false; 395 while(1){ 396 if(buffer[i]==1&&buffer[i+1]==ESC_CDECL&& isCdecl == false ){ 397 isCdecl = true; 398 399 i+=2; 400 } 401 else if(buffer[i]==1&&buffer[i+1]==ESC_EXPORT&& isExport == false ){ 402 isExport = true; 403 404 i+=2; 405 } 406 else break; 407 } 408 409 i2=0; 410 if(buffer[i]==1&&buffer[i+1]==ESC_OPERATOR){ 411 SetError(126,NULL,nowLine); 412 return 0; 413 } 414 else{ 415 for(;;i++,i2++){ 416 if(!IsVariableChar(buffer[i])){ 417 temporary[i2]=0; 418 break; 419 } 420 temporary[i2]=buffer[i]; 421 } 422 } 423 424 if( isMacro ){ 425 //大文字に変換 426 CharUpper(temporary); 427 428 //マクロ関数の場合は名前リストに追加 429 extern char **ppMacroNames; 430 extern int MacroNum; 431 ppMacroNames=(char **)HeapReAlloc(hHeap,0,ppMacroNames,(MacroNum+1)*sizeof(char *)); 432 ppMacroNames[MacroNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1); 433 lstrcpy(ppMacroNames[MacroNum],temporary); 434 MacroNum++; 435 } 436 437 //重複チェック 438 if(GetDeclareHash(temporary)){ 439 SetError(15,temporary,nowLine); 440 return 0; 441 } 442 443 extern int SubNum; 444 SubNum++; 445 446 GlobalProc *pGlobalProc = new GlobalProc( namespaceScopes, temporary, kind, isMacro, isCdecl, isExport ); 447 448 //ID 449 static int id_base=0; 450 pGlobalProc->id = (id_base++); 451 452 if(isExport){ 453 pGlobalProc->Using(); 454 } 455 456 // パラメータを解析 457 // ※第1パラメータにに指定するデータの例:"( s As String ) As String" 458 pGlobalProc->SetParamsAndReturnType( buffer + i, nowLine, true ); 459 460 #ifdef _DEBUG 461 pGlobalProc->_paramStr = buffer + i; 462 #endif 463 464 465 return pGlobalProc; 466 } 467 bool GlobalProc::AddGlobalProc( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine ){ 468 GlobalProc *pGlobalProc = Create( namespaceScopes, buffer, nowLine ); 469 if( pGlobalProc == NULL ){ 470 return false; 471 } 472 473 474 ///////////////////////////////// 475 // ハッシュデータに追加 476 ///////////////////////////////// 477 478 int key; 479 key=hash_default(pGlobalProc->GetName().c_str()); 480 481 extern GlobalProc **ppSubHash; 482 if(ppSubHash[key]){ 483 GlobalProc *psi2; 484 psi2=ppSubHash[key]; 485 while(1){ 486 //重複エラーチェックを行う 487 if( pGlobalProc->GetName() == psi2->GetName() ){ 488 if( Parameter::Equals( psi2->Params(), pGlobalProc->Params() ) ){ 489 SetError(15,pGlobalProc->GetName().c_str(),nowLine); 490 return 0; 491 } 492 } 493 494 if(psi2->pNextData==0) break; 495 psi2=psi2->pNextData; 496 } 497 psi2->pNextData=pGlobalProc; 498 } 499 else{ 500 ppSubHash[key]=pGlobalProc; 501 } 502 503 return true; 504 } 505 bool GlobalProc::EqualName( const string &name ) const 506 { 507 char AreaName[VN_SIZE]; //オブジェクト変数 508 char NestName[VN_SIZE]; //入れ子メンバ 509 bool isNest = SplitMemberName( name.c_str(), AreaName, NestName ); 510 511 if( isNest ){ 512 if( GetNamespaceScopes().Equal( AreaName ) ){ 513 if( GetName() == NestName ){ 514 return true; 515 } 516 } 517 } 518 else{ 519 if( GetNamespaceScopes().size() ){ 520 // 名前空間の判断が必要なとき 521 if( !GetNamespaceScopes().IsUsing() ){ 522 // この名前空間は暗黙的に参照できないとき 523 return false; 524 } 525 } 526 if( GetName() == name ){ 527 return true; 528 } 529 } 530 531 return false; 532 } 357 533 358 534 bool DllProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){ -
BasicCompiler_Common/Procedure.h
r97 r100 1 1 #pragma once 2 3 #include <Namespace.h> 4 #include "Parameter.h" 5 #include "Variable.h" 6 7 class CClass; 8 class CMethod; 2 9 3 10 class Procedure{ … … 10 17 11 18 private: 12 const string name; 19 const string name; // プロシージャ名 13 20 14 21 Kind kind; … … 109 116 110 117 public: 111 // ハッシュリスト用112 UserProc *pNextData;113 118 114 119 UserProc( const string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport ): … … 121 126 isAutoGeneration( false ), 122 127 isCompiled( false ), 123 pNextData( NULL ),124 128 beginOpAddress( 0 ), 125 129 endOpAddress( 0 ) … … 132 136 } 133 137 134 string GetFullName() const 135 { 136 if( HasParentClass() ){ 137 return (string)GetParentClass().name + "." + GetName(); 138 } 139 140 return GetName(); 141 } 138 string GetFullName() const; 142 139 143 140 bool IsMacro() const … … 214 211 return ( GetName()[0] == '~' ); 215 212 } 216 bool IsVirtual() const 217 { 218 if( pMethod == NULL ){ 219 return false; 220 } 221 return ( pMethod->bVirtual != 0 ); 222 } 223 213 bool IsVirtual() const; 224 214 225 215 // バイナリコードの位置 … … 259 249 return *pCompilingUserProc; 260 250 } 251 252 virtual bool EqualName( const string &name ) const; 253 }; 254 255 class GlobalProc : public UserProc 256 { 257 const NamespaceScopes namespaceScopes; 258 public: 259 // ハッシュリスト用 260 GlobalProc *pNextData; 261 262 GlobalProc( const NamespaceScopes &namespaceScopes, const string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport ): 263 UserProc( name, kind, isMacro, isCdecl, isExport ), 264 namespaceScopes( namespaceScopes ), 265 pNextData( NULL ) 266 {} 267 ~GlobalProc(){} 268 269 GlobalProc *Create( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine ); 270 bool AddGlobalProc( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine ); 271 272 const NamespaceScopes &GetNamespaceScopes() const 273 { 274 return namespaceScopes; 275 } 276 277 virtual bool EqualName( const string &name ) const; 261 278 }; 262 279 263 280 class DllProc : public Procedure 264 281 { 282 const NamespaceScopes namespaceScopes; 283 265 284 const string dllFileName; 266 285 const string alias; … … 271 290 DllProc *pNextData; 272 291 273 DllProc( const string &name, Kind kind, bool isCdecl, const string &dllFileName, const string &alias ):292 DllProc( const NamespaceScopes &namespaceScopes, const string &name, Kind kind, bool isCdecl, const string &dllFileName, const string &alias ): 274 293 Procedure( name, kind, isCdecl ), 294 namespaceScopes( namespaceScopes ), 275 295 dllFileName( dllFileName ), 276 296 alias( alias ), -
BasicCompiler_Common/Subroutine.cpp
r99 r100 99 99 } 100 100 if( lastIndex == -1 ){ 101 lstrcpy( member, desc ); 101 102 return false; 102 103 } … … 298 299 //インデクサ(getter)の戻り値を取得 299 300 bool GetReturnTypeOfIndexerGetterProc( const CClass &objClass, Type &resultType ){ 300 std::vector<UserProc *> subs;301 vector<UserProc *> subs; 301 302 objClass.EnumMethod( CALC_ARRAY_GET, subs ); 302 303 if( subs.size() == 0 ){ … … 310 311 311 312 312 void AddDeclareData(c har *buffer,int nowLine){313 void AddDeclareData(const NamespaceScopes &namespaceScopes, char *buffer,int nowLine){ 313 314 extern HANDLE hHeap; 314 315 int i2; … … 401 402 402 403 // オブジェクトを生成 403 DllProc *pDllProc = new DllProc( procName, kind, isCdecl, dllFileName, alias );404 DllProc *pDllProc = new DllProc( namespaceScopes, procName, kind, isCdecl, dllFileName, alias ); 404 405 405 406 // パラメータを解析 … … 462 463 } 463 464 464 UserProc *AddSubData(char *buffer,int nowLine,BOOL bVirtual,CClass *pobj_c, bool isStatic){465 GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine,BOOL bVirtual,CClass *pobj_c, bool isStatic){ 465 466 int i2,i3; 466 467 char temporary[8192]; … … 468 469 int i=1; 469 470 470 UserProc::Kind kind = Procedure::Sub;471 Procedure::Kind kind = Procedure::Sub; 471 472 bool isMacro = false; 472 473 if(buffer[i]==ESC_FUNCTION) kind = Procedure::Function; … … 583 584 SubNum++; 584 585 585 UserProc *pUserProc = new UserProc(temporary, kind, isMacro, isCdecl, isExport );586 GlobalProc *pUserProc = new GlobalProc( namespaceScopes, temporary, kind, isMacro, isCdecl, isExport ); 586 587 pUserProc->SetParentClass( pobj_c ); 587 588 … … 610 611 key=hash_default(pUserProc->GetName().c_str()); 611 612 612 extern UserProc **ppSubHash;613 extern GlobalProc **ppSubHash; 613 614 if(ppSubHash[key]){ 614 UserProc *psi2;615 GlobalProc *psi2; 615 616 psi2=ppSubHash[key]; 616 617 while(1){ … … 648 649 649 650 //サブルーチン(ユーザー定義)情報を初期化 650 extern UserProc **ppSubHash;651 extern GlobalProc **ppSubHash; 651 652 extern int SubNum; 652 ppSubHash=( UserProc **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(UserProc *));653 ppSubHash=(GlobalProc **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(GlobalProc *)); 653 654 SubNum=0; 654 655 … … 660 661 661 662 // 名前空間管理 662 vector<string>namespaceScopes;663 NamespaceScopes namespaceScopes; 663 664 664 665 i=-1; … … 715 716 if(basbuf[i]=='\0') break; 716 717 } 717 AddDeclareData( temporary,i);718 AddDeclareData(namespaceScopes,temporary,i); 718 719 719 720 continue; … … 728 729 if(basbuf[i]=='\0') break; 729 730 } 730 AddSubData( temporary,i,0,0);731 AddSubData(namespaceScopes,temporary,i,0,0); 731 732 732 733 continue; … … 743 744 // 特殊関数 744 745 //////////// 746 namespaceScopes.clear(); 745 747 746 748 sprintf(temporary,"%c%c_allrem()",1,ESC_SUB); 747 AddSubData( temporary,0,0,0);749 AddSubData( namespaceScopes, temporary,0,0,0); 748 750 749 751 sprintf(temporary,"%c%c_aullrem()",1,ESC_SUB); 750 AddSubData( temporary,0,0,0);752 AddSubData( namespaceScopes, temporary,0,0,0); 751 753 752 754 sprintf(temporary,"%c%c_allmul()",1,ESC_SUB); 753 AddSubData( temporary,0,0,0);755 AddSubData( namespaceScopes, temporary,0,0,0); 754 756 755 757 sprintf(temporary,"%c%c_alldiv()",1,ESC_SUB); 756 AddSubData( temporary,0,0,0);758 AddSubData( namespaceScopes, temporary,0,0,0); 757 759 758 760 sprintf(temporary,"%c%c_aulldiv()",1,ESC_SUB); 759 AddSubData( temporary,0,0,0);761 AddSubData( namespaceScopes, temporary,0,0,0); 760 762 761 763 sprintf(temporary,"%c%c_allshl()",1,ESC_SUB); 762 AddSubData( temporary,0,0,0);764 AddSubData( namespaceScopes, temporary,0,0,0); 763 765 764 766 sprintf(temporary,"%c%c_allshr()",1,ESC_SUB); 765 AddSubData( temporary,0,0,0);767 AddSubData( namespaceScopes, temporary,0,0,0); 766 768 767 769 sprintf(temporary,"%c%c_aullshr()",1,ESC_SUB); 768 AddSubData( temporary,0,0,0);770 AddSubData( namespaceScopes, temporary,0,0,0); 769 771 770 772 sprintf(temporary,"%c%c_System_InitStaticLocalVariables()",1,ESC_SUB); 771 AddSubData( temporary,0,0,0);772 } 773 void Delete_si( UserProc *pUserProc){773 AddSubData( namespaceScopes, temporary,0,0,0); 774 } 775 void Delete_si(GlobalProc *pUserProc){ 774 776 if(pUserProc->pNextData) Delete_si(pUserProc->pNextData); 775 777 delete pUserProc; 776 778 } 777 void DeleteSubInfo( UserProc **ppSubHash,char **ppMacroNames,int MacroNum){ //サブルーチン情報のメモリ解放779 void DeleteSubInfo(GlobalProc **ppSubHash,char **ppMacroNames,int MacroNum){ //サブルーチン情報のメモリ解放 778 780 int i; 779 781 for(i=0;i<MAX_HASH;i++){ … … 845 847 bool IsNeedProcCompile(){ 846 848 for(int i2=0;i2<MAX_HASH;i2++){ 847 extern UserProc **ppSubHash;848 UserProc *pUserProc=ppSubHash[i2];849 extern GlobalProc **ppSubHash; 850 GlobalProc *pUserProc=ppSubHash[i2]; 849 851 while(pUserProc){ 850 852 if( pUserProc->IsUsing() && pUserProc->IsCompiled() == false ){ -
BasicCompiler_Common/VarList.cpp
r92 r100 346 346 if(pobj_dti->lplpSpBase[i2]==0) return; 347 347 348 extern UserProc **ppSubHash;349 UserProc *pUserProc;348 extern GlobalProc **ppSubHash; 349 GlobalProc *pUserProc; 350 350 for(i3=0,sw=0;i3<MAX_HASH;i3++){ 351 351 pUserProc=ppSubHash[i3]; … … 589 589 590 590 //プロシージャ コンボボックス 591 extern UserProc **ppSubHash;592 UserProc *pUserProc;591 extern GlobalProc **ppSubHash; 592 GlobalProc *pUserProc; 593 593 int sw; 594 594 SendMessage(hProcCombo,CB_RESETCONTENT,0,0); … … 708 708 709 709 if(pobj_dti->lplpSpBase[i2]){ 710 extern UserProc **ppSubHash;711 UserProc *pUserProc;710 extern GlobalProc **ppSubHash; 711 GlobalProc *pUserProc; 712 712 for(i3=0,sw=0;i3<MAX_HASH;i3++){ 713 713 pUserProc=ppSubHash[i3]; -
BasicCompiler_Common/Variable.h
r75 r100 1 #pragma once 2 3 #include "Type.h" 1 4 2 5 class Variable : public Type -
BasicCompiler_Common/WatchList.cpp
r78 r100 311 311 } 312 312 ULONG_PTR Debugging_GetThisPtrOffset(LONG_PTR obp_Rip){ 313 UserProc *pUserProc = GetSubFromObp(obp_Rip);313 GlobalProc *pUserProc = GetSubFromObp(obp_Rip); 314 314 315 315 foreach( Variable *pVar, pUserProc->localVars ){ -
BasicCompiler_Common/common.h
r98 r100 325 325 void Debugger_Pause(void); 326 326 ULONG_PTR rva_to_real(DWORD p); 327 UserProc *GetSubFromObp(ULONG_PTR pos);327 GlobalProc *GetSubFromObp(ULONG_PTR pos); 328 328 void ReadOpBuffer(); 329 329 void DebugProgram(void); … … 442 442 bool GetReturnTypeOfPropertyMethod( const char *variable, const char *rightSide, Type &resultType ); 443 443 bool GetReturnTypeOfIndexerGetterProc( const CClass &objClass, Type &resultType ); 444 UserProc *AddSubData(char *buffer,int nowLine,BOOL bVirtual,CClass *pobj_c, bool isStatic = false );444 GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine,BOOL bVirtual,CClass *pobj_c, bool isStatic = false ); 445 445 void GetSubInfo(void); 446 void DeleteSubInfo( UserProc **ppSubHash,char **ppMacroNames,int MacroNum);446 void DeleteSubInfo(GlobalProc **ppSubHash,char **ppMacroNames,int MacroNum); 447 447 void DeleteDeclareInfo(void); 448 448 int AddProcPtrInfo( const string &typeExpression, int nowLine ); -
BasicCompiler_Common/hash.cpp
r97 r100 68 68 char NestMember[VN_SIZE]; //入れ子メンバ 69 69 bool isObjectMember = SplitMemberName( name, ObjName, NestMember ); 70 if( !isObjectMember ) lstrcpy(ObjName,name);71 70 72 71 if(isObjectMember){ … … 82 81 //"->"によってオブジェクトを指定する通常のメンバ関数呼び出し 83 82 Type type; 84 GetVarType(ObjName,type,0); 85 pobj_c = &type.GetClass(); 86 if((NATURAL_TYPE(type.GetBasicType())!=DEF_OBJECT)){ 83 if( GetVarType(ObjName,type,0) ){ 84 pobj_c = &type.GetClass(); 85 } 86 else{ 87 87 pobj_c=pobj_DBClass->check(ObjName); 88 88 if( pobj_c ){ 89 89 isStatic = true; 90 90 } 91 else{92 return;93 }94 91 } 95 92 } 96 93 97 if( isStatic ){ 98 // 静的メソッドから列挙 99 pobj_c->EnumStaticMethod( NestMember, subs ); 100 } 101 else{ 102 //動的メソッドから列挙 103 pobj_c->EnumMethod( NestMember, subs ); 94 if( pobj_c ){ 95 if( isStatic ){ 96 // 静的メソッドから列挙 97 pobj_c->EnumStaticMethod( NestMember, subs ); 98 } 99 else{ 100 //動的メソッドから列挙 101 pobj_c->EnumMethod( NestMember, subs ); 102 } 103 return; 104 104 } 105 105 } 106 else{107 //オブジェクトが明示的に指定されていないとき108 106 109 if(pobj_CompilingClass){110 //自身のオブジェクトのメンバ関数を検索111 107 112 // 静的メソッド113 pobj_CompilingClass->EnumStaticMethod( name, subs );108 if(pobj_CompilingClass){ 109 //自身のオブジェクトのメンバ関数を検索 114 110 115 // 動的メソッド 116 pobj_CompilingClass->EnumMethod( name, subs ); 111 // 静的メソッド 112 pobj_CompilingClass->EnumStaticMethod( name, subs ); 113 114 // 動的メソッド 115 pobj_CompilingClass->EnumMethod( name, subs ); 116 } 117 118 119 /////////////////////////// 120 // グローバル関数を検索 121 /////////////////////////// 122 123 //ハッシュ値を取得 124 int key; 125 key=hash_default(NestMember); 126 127 //格納位置を取得 128 extern GlobalProc **ppSubHash; 129 GlobalProc *pUserProc; 130 pUserProc=ppSubHash[key]; 131 while(pUserProc){ 132 if(!pUserProc->GetParentClassPtr()){ 133 if( pUserProc->EqualName( name ) ){ 134 subs.push_back( pUserProc ); 135 } 117 136 } 118 137 119 120 /////////////////////////// 121 // グローバル関数を検索 122 /////////////////////////// 123 124 //ハッシュ値を取得 125 int key; 126 key=hash_default(name); 127 128 //格納位置を取得 129 extern UserProc **ppSubHash; 130 UserProc *pUserProc; 131 pUserProc=ppSubHash[key]; 132 while(pUserProc){ 133 if(!pUserProc->GetParentClassPtr()){ 134 if( pUserProc->GetName() == name ){ 135 subs.push_back( pUserProc ); 136 } 137 } 138 139 pUserProc=pUserProc->pNextData; 140 } 141 138 pUserProc=pUserProc->pNextData; 142 139 } 143 140 } -
BasicCompiler_Common/include/Smoothie.h
r95 r100 3 3 #include "Source.h" 4 4 #include "../TypeDef.h" 5 #include "Namespace.h" 5 6 6 7 class Smoothie{
Note:
See TracChangeset
for help on using the changeset viewer.