Changeset 100 in dev


Ignore:
Timestamp:
Apr 24, 2007, 3:17:29 AM (17 years ago)
Author:
dai_9181
Message:

名前空間機能をグローバル関数に適用。

Files:
1 added
25 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler32/BasicCompiler.vcproj

    r91 r100  
    19381938                    Name="Meta Parts"
    19391939                    >
     1940                    <File
     1941                        RelativePath="..\BasicCompiler_Common\include\Namespace.h"
     1942                        >
     1943                    </File>
    19401944                    <File
    19411945                        RelativePath="..\BasicCompiler_Common\Parameter.h"
  • BasicCompiler32/Compile_ProcOp.cpp

    r95 r100  
    229229    extern char *basbuf;
    230230    extern HANDLE hHeap;
    231     extern UserProc **ppSubHash;
     231    extern GlobalProc **ppSubHash;
    232232    extern BOOL bDebugCompile;
    233233    int i3,i4,LocalVarSchedule,EspOffsetSchedule,BaseOffset;
     
    865865}
    866866void CompileLocal(){
    867     extern UserProc **ppSubHash;
     867    extern GlobalProc **ppSubHash;
    868868    int i2;
    869     UserProc *pUserProc;
    870869
    871870    extern BOOL bDll;
    872871    if(bDll){
    873872        //DLLの場合はグローバル変数を初期化するための関数を一番初めにコンパイルする
    874         pUserProc=GetSubHash("_System_InitDllGlobalVariables");
     873        UserProc *pUserProc=GetSubHash("_System_InitDllGlobalVariables");
    875874        if(pUserProc){
    876875            CompileBufferInProcedure( *pUserProc );
     
    893892
    894893repeat:
     894    GlobalProc *pGlobalProc;
    895895    for(i2=0;i2<MAX_HASH;i2++){
    896         pUserProc=ppSubHash[i2];
    897         while(pUserProc){
    898             CompileBufferInProcedure( *pUserProc );
    899             pUserProc=pUserProc->pNextData;
     896        pGlobalProc=ppSubHash[i2];
     897        while(pGlobalProc){
     898            CompileBufferInProcedure( *pGlobalProc );
     899            pGlobalProc=pGlobalProc->pNextData;
    900900        }
    901901    }
     
    913913        //プロシージャコンパイルによって、プロシージャコンパイルが必要になる場合
    914914        for(i2=0;i2<MAX_HASH;i2++){
    915             pUserProc=ppSubHash[i2];
    916             while(pUserProc){
    917                 CompileBufferInProcedure( *pUserProc );
    918                 pUserProc=pUserProc->pNextData;
     915            pGlobalProc=ppSubHash[i2];
     916            while(pGlobalProc){
     917                CompileBufferInProcedure( *pGlobalProc );
     918                pGlobalProc=pGlobalProc->pNextData;
    919919            }
    920920        }
  • BasicCompiler32/MakePeHdr.cpp

    r95 r100  
    558558        ExportNamesLength=lstrlen(lpExportNames)+1;
    559559
    560         extern UserProc **ppSubHash;
    561         UserProc *pUserProc,*psi2;
     560        extern GlobalProc **ppSubHash;
     561        GlobalProc *pUserProc,*psi2;
    562562        while(1){
    563563            //辞書順にサーチ
  • BasicCompiler64/BasicCompiler.vcproj

    r97 r100  
    577577                    Name="Meta Parts"
    578578                    >
     579                    <File
     580                        RelativePath="..\BasicCompiler_Common\include\Namespace.h"
     581                        >
     582                    </File>
    579583                    <File
    580584                        RelativePath="..\BasicCompiler_Common\Parameter.h"
  • BasicCompiler64/Compile_ProcOp.cpp

    r95 r100  
    219219    extern char *basbuf;
    220220    extern HANDLE hHeap;
    221     extern UserProc **ppSubHash;
     221    extern GlobalProc **ppSubHash;
    222222    extern BOOL bDebugCompile;
    223223    int i3,i4;
     
    830830    temporary[0]=0;
    831831    lstrcat( temporary, "------------------------------------------------------------------\n" );
    832     sprintf( temporary + lstrlen(temporary), "【 %s のコード情報】\n", userProc.GetFullName().c_str() );
     832    sprintf( temporary + lstrlen(temporary), "【 %s のコード情報】\n", userProc.GetName().c_str() );
    833833    sprintf( temporary + lstrlen(temporary), "code size: %d bytes\n", userProc.GetCodeSize() );
    834834    lstrcat( temporary, "------------------------------------------------------------------\n" );
     
    837837}
    838838void CompileLocal(){
    839     extern UserProc **ppSubHash;
     839    extern GlobalProc **ppSubHash;
    840840    int i2;
    841     UserProc *pUserProc;
    842841
    843842    extern BOOL bDll;
    844843    if(bDll){
    845844        //DLLの場合はグローバル変数を初期化するための関数を一番初めにコンパイルする
    846         pUserProc=GetSubHash("_System_InitDllGlobalVariables");
     845        UserProc *pUserProc=GetSubHash("_System_InitDllGlobalVariables");
    847846        if(pUserProc){
    848847            CompileBufferInProcedure( *pUserProc );
     
    865864
    866865repeat:
     866    GlobalProc *pGlobalProc;
    867867    for(i2=0;i2<MAX_HASH;i2++){
    868         pUserProc=ppSubHash[i2];
    869         while(pUserProc){
    870             CompileBufferInProcedure( *pUserProc );
    871             pUserProc=pUserProc->pNextData;
     868        pGlobalProc=ppSubHash[i2];
     869        while(pGlobalProc){
     870            CompileBufferInProcedure( *pGlobalProc );
     871            pGlobalProc=pGlobalProc->pNextData;
    872872        }
    873873    }
     
    885885        //プロシージャコンパイルによって、プロシージャコンパイルが必要になる場合
    886886        for(i2=0;i2<MAX_HASH;i2++){
    887             pUserProc=ppSubHash[i2];
    888             while(pUserProc){
    889                 CompileBufferInProcedure( *pUserProc );
    890                 pUserProc=pUserProc->pNextData;
     887            pGlobalProc=ppSubHash[i2];
     888            while(pGlobalProc){
     889                CompileBufferInProcedure( *pGlobalProc );
     890                pGlobalProc=pGlobalProc->pNextData;
    891891            }
    892892        }
  • BasicCompiler64/MakePeHdr.cpp

    r95 r100  
    531531        ExportNamesLength=lstrlen(lpExportNames)+1;
    532532
    533         extern UserProc **ppSubHash;
    534         UserProc *pUserProc,*psi2;
     533        extern GlobalProc **ppSubHash;
     534        GlobalProc *pUserProc,*psi2;
    535535        while(1){
    536536            //辞書順にサーチ
  • BasicCompiler_Common/BasicCompiler.h

    r97 r100  
    2323DWORD ImageBase;
    2424INCLUDEFILEINFO IncludeFileInfo;
    25 UserProc **ppSubHash;
     25GlobalProc **ppSubHash;
    2626int SubNum;
    2727char **ppMacroNames;
  • BasicCompiler_Common/Class.cpp

    r97 r100  
    118118
    119119
    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//コピーコンストラクタ
     121CMethod::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
     131CMethod::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{
    132140}
    133141CMethod::~CMethod(){
     
    330338}
    331339void 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 );
    339341
    340342    methods.push_back( method );
     
    344346}
    345347void 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 );
    352349
    353350    staticMethods.push_back( method );
     
    421418}
    422419
    423 void CClass::EnumStaticMethod( const char *methodName, std::vector<UserProc *> &subs ) const
     420void CClass::EnumStaticMethod( const char *methodName, vector<UserProc *> &subs ) const
    424421{
    425422    foreach( CMethod *method, staticMethods ){
     
    430427}
    431428
    432 void CClass::EnumMethod( const char *methodName, std::vector<UserProc *> &subs ) const
     429void CClass::EnumMethod( const char *methodName, vector<UserProc *> &subs ) const
    433430{
    434431    //オブジェクトのメンバ関数の場合
     
    441438}
    442439
    443 void CClass::EnumMethod( const BYTE idOperatorCalc, std::vector<UserProc *> &subs ) const
     440void CClass::EnumMethod( const BYTE idOperatorCalc, vector<UserProc *> &subs ) const
    444441{
    445442    //オブジェクトのメンバ関数の場合
     
    603600
    604601    UserProc **ppsi;
    605     ppsi=(UserProc **)HeapAlloc(hHeap,0,vtbl_num*sizeof(UserProc *));
     602    ppsi=(UserProc **)HeapAlloc(hHeap,0,vtbl_num*sizeof(GlobalProc *));
    606603
    607604    //関数テーブルに値をセット
     
    642639    int i;
    643640    for(i=0;i<vtbl_num;i++){
    644         UserProc *pUserProc;
    645         pUserProc=(UserProc *)pVtbl[i];
     641        GlobalProc *pUserProc;
     642        pUserProc=(GlobalProc *)pVtbl[i];
    646643        if(!pUserProc) continue;
    647644        pVtbl[i]=pUserProc->beginOpAddress+ImageBase+MemPos_CodeSection;
     
    803800        }
    804801    }
    805     return 0;
     802    return NULL;
    806803}
    807804
     
    932929
    933930    //関数ハッシュへ登録
    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) );
    936933    if(!pUserProc) return;
    937934
  • BasicCompiler_Common/Class.h

    r97 r100  
    33#include <vector>
    44#include "Type.h"
     5#include "Procedure.h"
    56
    67class CClass;
    7 class UserProc;
    88
    99#define ACCESS_NON          0
     
    3737    static void InitStaticMember(void);
    3838};
    39 class CMethod{
     39class CMethod
     40{
    4041public:
    4142    UserProc *pUserProc;
     43
    4244    DWORD dwAccess;
    4345    BOOL bAbstract;
    4446    BOOL bVirtual;
    4547    bool isConst;
     48    bool isStatic;
    4649
    4750    CClass *pobj_InheritsClass;
    4851
    4952    CMethod(CMethod *pobj);
    50     CMethod();
     53    CMethod( UserProc *pUserProc, DWORD dwAccess, BOOL bAbstract, BOOL bVirtual, bool isConst, bool isStatic );
    5154    ~CMethod();
    5255};
     56
    5357class CDBClass;
    5458class CDebugSection;
     
    135139
    136140    //メソッドを列挙
    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;
    140144    const std::vector<CMethod *> &GetMethods() const
    141145    {
  • BasicCompiler_Common/Debug.cpp

    r75 r100  
    224224    SendDlgItemMessage(hMainDlg,IDC_DEBUGLIST,EM_REPLACESEL,0,(LPARAM)buffer);
    225225}
    226 UserProc *GetSubFromObp(ULONG_PTR pos){
    227     extern UserProc **ppSubHash;
    228     UserProc *pUserProc;
     226GlobalProc *GetSubFromObp(ULONG_PTR pos){
     227    extern GlobalProc **ppSubHash;
     228    GlobalProc *pUserProc;
    229229    int i2;
    230230
     
    447447    pobj_dti=new CDebugThreadInfo();
    448448
    449     UserProc *pUserProc;
     449    GlobalProc *pUserProc;
    450450
    451451    extern DWORD dwStepRun;
  • BasicCompiler_Common/DebugMiddleFile.cpp

    r88 r100  
    205205
    206206    //プロシージャ情報
    207     extern UserProc **ppSubHash;
     207    extern GlobalProc **ppSubHash;
    208208    extern int SubNum;
    209     UserProc *pUserProc;
     209    GlobalProc *pUserProc;
    210210    *(long *)(buffer+i2)=SubNum;
    211211    i2+=sizeof(long);
     
    574574
    575575    //プロシージャ情報
    576     UserProc *pUserProc;
     576    GlobalProc *pUserProc;
    577577    SubNum=*(long *)(buffer+i2);
    578578    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 *));
    580580    for(int i6=0;i6<SubNum;i6++){
    581581        char szParentClassName[VN_SIZE];
     
    596596
    597597        // オブジェクトを生成
    598         pUserProc = new UserProc( name, UserProc::Function, false, false, false );
     598        // TODO: 名前空間が未完成
     599        pUserProc = new GlobalProc( NamespaceScopes(), name, Procedure::Function, false, false, false );
    599600        pUserProc->pNextData=0;
    600601        pUserProc->id=id;
     
    664665        i4=hash_default(pUserProc->GetName().c_str());
    665666
    666         UserProc *psi2;
     667        GlobalProc *psi2;
    667668        if(ppSubHash[i4]){
    668669            psi2=ppSubHash[i4];
     
    730731        i2+=sizeof(long);
    731732        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);
    735735            i2+=sizeof(long);
    736736
     
    739739            i2+=lstrlen(buffer+i2)+1;
    740740
    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            }
    744745
    745746            lstrcpy(temp2,buffer+i2);
     
    747748
    748749            CClass *pobj_temp_c;
    749             pobj_temp_c=method->pobj_InheritsClass;
     750            pobj_temp_c=pobj_InheritsClass;
    750751            if(pobj_temp_c==0) pobj_temp_c=pobj_c;
    751752            i5=hash_default(temp2);
     
    755756                pUserProc=pUserProc->pNextData;
    756757            }
    757             method->pUserProc=pUserProc;
     758
     759            CMethod *method = new CMethod( pUserProc, dwAccess, 0,0,false, false);
     760            method->pobj_InheritsClass = pobj_InheritsClass;
    758761
    759762            pobj_c->methods.push_back( method );
     
    795798
    796799
    797     extern UserProc **ppSubHash;
     800    extern GlobalProc **ppSubHash;
    798801    ppSubHash=this->ppSubHash;
    799802    pSub_DebugSys_EndProc=GetSubHash("_DebugSys_EndProc");
     
    951954    extern char **ppMacroNames;
    952955    ppMacroNames=0;
    953     extern UserProc **ppSubHash;
     956    extern GlobalProc **ppSubHash;
    954957    extern int SubNum;
    955958    ppSubHash=this->ppSubHash;
  • BasicCompiler_Common/DebugSection.h

    r88 r100  
    4141
    4242    //プロシージャ
    43     UserProc **ppSubHash;
     43    GlobalProc **ppSubHash;
    4444    int SubNum;
    4545
  • BasicCompiler_Common/Diagnose.cpp

    r92 r100  
    3434        int codeSizeOfClassMethod = 0;
    3535        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];
    3838            while(pUserProc){
    3939                if( pUserProc->IsCompiled() ){
  • BasicCompiler_Common/Intermediate_Step2.cpp

    r92 r100  
    432432            case ESC_MACRO:
    433433            case ESC_STATIC:
     434            case ESC_NAMESPACE:
    434435                KillStringSpaces(Command+2);
    435436                break;
  • BasicCompiler_Common/MakeExe.cpp

    r96 r100  
    197197
    198198    //サブルーチン(ユーザー定義)情報のメモリ解放
    199     extern UserProc **ppSubHash;
     199    extern GlobalProc **ppSubHash;
    200200    extern char **ppMacroNames;
    201201    extern int MacroNum;
  • BasicCompiler_Common/ParamImpl.cpp

    r90 r100  
    88
    99#define OVERLOAD_MIN_LEVEL 0
    10 #define OVERLOAD_MAX_LEVEL 4
     10#define OVERLOAD_MAX_LEVEL 5
    1111#define OVERLOAD_LEVEL0 0       // 型調整なし。厳密に等しい
    1212#define OVERLOAD_LEVEL1 1       // 型調整なし。レベル1以上はオブジェクトの場合は派生関係を考慮
  • BasicCompiler_Common/Procedure.cpp

    r79 r100  
    11#include "common.h"
    22
     3string UserProc::GetFullName() const
     4{
     5    if( HasParentClass() ){
     6        return (string)GetParentClass().name + "." + GetName();
     7    }
     8
     9    return GetName();
     10}
    311bool UserProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic ){
    412    int i = 0;
     
    355363    return true;
    356364}
     365bool UserProc::IsVirtual() const
     366{
     367    if( pMethod == NULL ){
     368        return false;
     369    }
     370    return ( pMethod->bVirtual != 0 );
     371}
     372bool UserProc::EqualName( const string &name ) const
     373{
     374    SetError();
     375    return true;
     376}
     377
     378GlobalProc *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}
     467bool 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}
     505bool 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}
    357533
    358534bool DllProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){
  • BasicCompiler_Common/Procedure.h

    r97 r100  
    11#pragma once
     2
     3#include <Namespace.h>
     4#include "Parameter.h"
     5#include "Variable.h"
     6
     7class CClass;
     8class CMethod;
    29
    310class Procedure{
     
    1017
    1118private:
    12     const string name;
     19    const string name;                      // プロシージャ名
    1320
    1421    Kind kind;
     
    109116
    110117public:
    111     // ハッシュリスト用
    112     UserProc *pNextData;
    113118
    114119    UserProc( const string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport ):
     
    121126      isAutoGeneration( false ),
    122127      isCompiled( false ),
    123       pNextData( NULL ),
    124128      beginOpAddress( 0 ),
    125129      endOpAddress( 0 )
     
    132136    }
    133137
    134     string GetFullName() const
    135     {
    136         if( HasParentClass() ){
    137             return (string)GetParentClass().name + "." + GetName();
    138         }
    139 
    140         return GetName();
    141     }
     138    string GetFullName() const;
    142139
    143140    bool IsMacro() const
     
    214211        return ( GetName()[0] == '~' );
    215212    }
    216     bool IsVirtual() const
    217     {
    218         if( pMethod == NULL ){
    219             return false;
    220         }
    221         return ( pMethod->bVirtual != 0 );
    222     }
    223 
     213    bool IsVirtual() const;
    224214
    225215    // バイナリコードの位置
     
    259249        return *pCompilingUserProc;
    260250    }
     251
     252    virtual bool EqualName( const string &name ) const;
     253};
     254
     255class GlobalProc : public UserProc
     256{
     257    const NamespaceScopes namespaceScopes;
     258public:
     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;
    261278};
    262279
    263280class DllProc : public Procedure
    264281{
     282    const NamespaceScopes namespaceScopes;
     283
    265284    const string dllFileName;
    266285    const string alias;
     
    271290    DllProc *pNextData;
    272291
    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 ):
    274293      Procedure( name, kind, isCdecl ),
     294      namespaceScopes( namespaceScopes ),
    275295      dllFileName( dllFileName ),
    276296      alias( alias ),
  • BasicCompiler_Common/Subroutine.cpp

    r99 r100  
    9999    }
    100100    if( lastIndex == -1 ){
     101        lstrcpy( member, desc );
    101102        return false;
    102103    }
     
    298299//インデクサ(getter)の戻り値を取得
    299300bool GetReturnTypeOfIndexerGetterProc( const CClass &objClass, Type &resultType ){
    300     std::vector<UserProc *> subs;
     301    vector<UserProc *> subs;
    301302    objClass.EnumMethod( CALC_ARRAY_GET, subs );
    302303    if( subs.size() == 0 ){
     
    310311
    311312
    312 void AddDeclareData(char *buffer,int nowLine){
     313void AddDeclareData(const NamespaceScopes &namespaceScopes, char *buffer,int nowLine){
    313314    extern HANDLE hHeap;
    314315    int i2;
     
    401402
    402403    // オブジェクトを生成
    403     DllProc *pDllProc = new DllProc( procName, kind, isCdecl, dllFileName, alias );
     404    DllProc *pDllProc = new DllProc( namespaceScopes, procName, kind, isCdecl, dllFileName, alias );
    404405
    405406    // パラメータを解析
     
    462463}
    463464
    464 UserProc *AddSubData(char *buffer,int nowLine,BOOL bVirtual,CClass *pobj_c, bool isStatic){
     465GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine,BOOL bVirtual,CClass *pobj_c, bool isStatic){
    465466    int i2,i3;
    466467    char temporary[8192];
     
    468469    int i=1;
    469470
    470     UserProc::Kind kind = Procedure::Sub;
     471    Procedure::Kind kind = Procedure::Sub;
    471472    bool isMacro = false;
    472473    if(buffer[i]==ESC_FUNCTION) kind = Procedure::Function;
     
    583584    SubNum++;
    584585
    585     UserProc *pUserProc = new UserProc( temporary, kind, isMacro, isCdecl, isExport );
     586    GlobalProc *pUserProc = new GlobalProc( namespaceScopes, temporary, kind, isMacro, isCdecl, isExport );
    586587    pUserProc->SetParentClass( pobj_c );
    587588
     
    610611    key=hash_default(pUserProc->GetName().c_str());
    611612
    612     extern UserProc **ppSubHash;
     613    extern GlobalProc **ppSubHash;
    613614    if(ppSubHash[key]){
    614         UserProc *psi2;
     615        GlobalProc *psi2;
    615616        psi2=ppSubHash[key];
    616617        while(1){
     
    648649
    649650    //サブルーチン(ユーザー定義)情報を初期化
    650     extern UserProc **ppSubHash;
     651    extern GlobalProc **ppSubHash;
    651652    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 *));
    653654    SubNum=0;
    654655
     
    660661
    661662    // 名前空間管理
    662     vector<string> namespaceScopes;
     663    NamespaceScopes namespaceScopes;
    663664
    664665    i=-1;
     
    715716                if(basbuf[i]=='\0') break;
    716717            }
    717             AddDeclareData(temporary,i);
     718            AddDeclareData(namespaceScopes,temporary,i);
    718719
    719720            continue;
     
    728729                if(basbuf[i]=='\0') break;
    729730            }
    730             AddSubData(temporary,i,0,0);
     731            AddSubData(namespaceScopes,temporary,i,0,0);
    731732
    732733            continue;
     
    743744    // 特殊関数
    744745    ////////////
     746    namespaceScopes.clear();
    745747
    746748    sprintf(temporary,"%c%c_allrem()",1,ESC_SUB);
    747     AddSubData(temporary,0,0,0);
     749    AddSubData( namespaceScopes, temporary,0,0,0);
    748750
    749751    sprintf(temporary,"%c%c_aullrem()",1,ESC_SUB);
    750     AddSubData(temporary,0,0,0);
     752    AddSubData( namespaceScopes, temporary,0,0,0);
    751753
    752754    sprintf(temporary,"%c%c_allmul()",1,ESC_SUB);
    753     AddSubData(temporary,0,0,0);
     755    AddSubData( namespaceScopes, temporary,0,0,0);
    754756
    755757    sprintf(temporary,"%c%c_alldiv()",1,ESC_SUB);
    756     AddSubData(temporary,0,0,0);
     758    AddSubData( namespaceScopes, temporary,0,0,0);
    757759
    758760    sprintf(temporary,"%c%c_aulldiv()",1,ESC_SUB);
    759     AddSubData(temporary,0,0,0);
     761    AddSubData( namespaceScopes, temporary,0,0,0);
    760762
    761763    sprintf(temporary,"%c%c_allshl()",1,ESC_SUB);
    762     AddSubData(temporary,0,0,0);
     764    AddSubData( namespaceScopes, temporary,0,0,0);
    763765
    764766    sprintf(temporary,"%c%c_allshr()",1,ESC_SUB);
    765     AddSubData(temporary,0,0,0);
     767    AddSubData( namespaceScopes, temporary,0,0,0);
    766768
    767769    sprintf(temporary,"%c%c_aullshr()",1,ESC_SUB);
    768     AddSubData(temporary,0,0,0);
     770    AddSubData( namespaceScopes, temporary,0,0,0);
    769771
    770772    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}
     775void Delete_si(GlobalProc *pUserProc){
    774776    if(pUserProc->pNextData) Delete_si(pUserProc->pNextData);
    775777    delete pUserProc;
    776778}
    777 void DeleteSubInfo(UserProc **ppSubHash,char **ppMacroNames,int MacroNum){  //サブルーチン情報のメモリ解放
     779void DeleteSubInfo(GlobalProc **ppSubHash,char **ppMacroNames,int MacroNum){    //サブルーチン情報のメモリ解放
    778780    int i;
    779781    for(i=0;i<MAX_HASH;i++){
     
    845847bool IsNeedProcCompile(){
    846848    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];
    849851        while(pUserProc){
    850852            if( pUserProc->IsUsing() && pUserProc->IsCompiled() == false ){
  • BasicCompiler_Common/VarList.cpp

    r92 r100  
    346346    if(pobj_dti->lplpSpBase[i2]==0) return;
    347347
    348     extern UserProc **ppSubHash;
    349     UserProc *pUserProc;
     348    extern GlobalProc **ppSubHash;
     349    GlobalProc *pUserProc;
    350350    for(i3=0,sw=0;i3<MAX_HASH;i3++){
    351351        pUserProc=ppSubHash[i3];
     
    589589
    590590    //プロシージャ コンボボックス
    591     extern UserProc **ppSubHash;
    592     UserProc *pUserProc;
     591    extern GlobalProc **ppSubHash;
     592    GlobalProc *pUserProc;
    593593    int sw;
    594594    SendMessage(hProcCombo,CB_RESETCONTENT,0,0);
     
    708708
    709709    if(pobj_dti->lplpSpBase[i2]){
    710         extern UserProc **ppSubHash;
    711         UserProc *pUserProc;
     710        extern GlobalProc **ppSubHash;
     711        GlobalProc *pUserProc;
    712712        for(i3=0,sw=0;i3<MAX_HASH;i3++){
    713713            pUserProc=ppSubHash[i3];
  • BasicCompiler_Common/Variable.h

    r75 r100  
     1#pragma once
     2
     3#include "Type.h"
    14
    25class Variable : public Type
  • BasicCompiler_Common/WatchList.cpp

    r78 r100  
    311311}
    312312ULONG_PTR Debugging_GetThisPtrOffset(LONG_PTR obp_Rip){
    313     UserProc *pUserProc = GetSubFromObp(obp_Rip);
     313    GlobalProc *pUserProc = GetSubFromObp(obp_Rip);
    314314
    315315    foreach( Variable *pVar, pUserProc->localVars ){
  • BasicCompiler_Common/common.h

    r98 r100  
    325325void Debugger_Pause(void);
    326326ULONG_PTR rva_to_real(DWORD p);
    327 UserProc *GetSubFromObp(ULONG_PTR pos);
     327GlobalProc *GetSubFromObp(ULONG_PTR pos);
    328328void ReadOpBuffer();
    329329void DebugProgram(void);
     
    442442bool GetReturnTypeOfPropertyMethod( const char *variable, const char *rightSide, Type &resultType );
    443443bool GetReturnTypeOfIndexerGetterProc( const CClass &objClass, Type &resultType );
    444 UserProc *AddSubData(char *buffer,int nowLine,BOOL bVirtual,CClass *pobj_c, bool isStatic = false );
     444GlobalProc *AddSubData( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine,BOOL bVirtual,CClass *pobj_c, bool isStatic = false );
    445445void GetSubInfo(void);
    446 void DeleteSubInfo(UserProc **ppSubHash,char **ppMacroNames,int MacroNum);
     446void DeleteSubInfo(GlobalProc **ppSubHash,char **ppMacroNames,int MacroNum);
    447447void DeleteDeclareInfo(void);
    448448int AddProcPtrInfo( const string &typeExpression, int nowLine );
  • BasicCompiler_Common/hash.cpp

    r97 r100  
    6868    char NestMember[VN_SIZE];   //入れ子メンバ
    6969    bool isObjectMember = SplitMemberName( name, ObjName, NestMember );
    70     if( !isObjectMember ) lstrcpy(ObjName,name);
    7170
    7271    if(isObjectMember){
     
    8281            //"->"によってオブジェクトを指定する通常のメンバ関数呼び出し
    8382            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{
    8787                pobj_c=pobj_DBClass->check(ObjName);
    8888                if( pobj_c ){
    8989                    isStatic = true;
    9090                }
    91                 else{
    92                     return;
    93                 }
    9491            }
    9592        }
    9693
    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;
    104104        }
    105105    }
    106     else{
    107         //オブジェクトが明示的に指定されていないとき
    108106
    109         if(pobj_CompilingClass){
    110             //自身のオブジェクトのメンバ関数を検索
    111107
    112             // 静的メソッド
    113             pobj_CompilingClass->EnumStaticMethod( name, subs );
     108    if(pobj_CompilingClass){
     109        //自身のオブジェクトのメンバ関数を検索
    114110
    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            }
    117136        }
    118137
    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;
    142139    }
    143140}
  • BasicCompiler_Common/include/Smoothie.h

    r95 r100  
    33#include "Source.h"
    44#include "../TypeDef.h"
     5#include "Namespace.h"
    56
    67class Smoothie{
Note: See TracChangeset for help on using the changeset viewer.