Changeset 101 in dev


Ignore:
Timestamp:
Apr 25, 2007, 4:19:28 AM (17 years ago)
Author:
dai_9181
Message:

名前空間機能をグローバル関数に適用(作業完了)。

Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler32/BasicCompiler.vcproj

    r100 r101  
    18331833                    Name="Meta Parts"
    18341834                    >
     1835                    <File
     1836                        RelativePath="..\BasicCompiler_Common\src\Namespace.cpp"
     1837                        >
     1838                    </File>
    18351839                    <File
    18361840                        RelativePath="..\BasicCompiler_Common\Procedure.cpp"
  • BasicCompiler32/Compile_ProcOp.cpp

    r100 r101  
    266266    //コンパイル中の関数
    267267    UserProc::CompileStartForUserProc( pUserProc );
     268
     269    // コンパイル中の関数が属する名前空間
     270    Smoothie::Lexical::liveingNamespaceScopes = pUserProc->GetNamespaceScopes();
    268271
    269272    if(pUserProc->IsSystem()){
  • BasicCompiler64/BasicCompiler.vcproj

    r100 r101  
    18211821                    >
    18221822                    <File
     1823                        RelativePath="..\BasicCompiler_Common\src\Namespace.cpp"
     1824                        >
     1825                    </File>
     1826                    <File
    18231827                        RelativePath="..\BasicCompiler_Common\Procedure.cpp"
    18241828                        >
  • BasicCompiler64/Compile_ProcOp.cpp

    r100 r101  
    256256    //コンパイル中の関数
    257257    UserProc::CompileStartForUserProc( pUserProc );
     258
     259    // コンパイル中の関数が属する名前空間
     260    Smoothie::Lexical::liveingNamespaceScopes = pUserProc->GetNamespaceScopes();
    258261
    259262    if(pUserProc->IsSystem()){
  • BasicCompiler_Common/Class.cpp

    r100 r101  
    144144
    145145
    146 CClass::CClass(const char *name):
     146CClass::CClass( const NamespaceScopes &namespaceScopes, const char *name ):
     147    namespaceScopes( namespaceScopes ),
    147148    ConstructorMemberSubIndex( 0 ),
    148149    DestructorMemberSubIndex( 0 ),
     
    193194}
    194195
     196bool CClass::IsEqualSymbol() const
     197{
     198    return false;
     199}
     200
    195201bool CClass::IsUsing() const
    196202{
     
    803809}
    804810
    805 CClass *CDBClass::AddClass(const char *name,int nowLine){
     811CClass *CDBClass::AddClass( const NamespaceScopes &namespaceScopes, const char *name,int nowLine){
    806812    //////////////////////////////////////////////////////////////////////////
    807813    // クラスを追加
     
    810816
    811817    CClass *pobj_c;
    812     pobj_c=new CClass(name);
     818    pobj_c=new CClass(namespaceScopes, name);
    813819
    814820    if(lstrcmp(name,"String")==0){
     
    852858void CDBClass::InitNames(void){
    853859    extern char *basbuf;
    854     int i;
     860    int i, i2;
     861    char temporary[VN_SIZE];
     862
     863    // 名前空間管理
     864    NamespaceScopes &namespaceScopes = Smoothie::Lexical::liveingNamespaceScopes;
     865    namespaceScopes.clear();
    855866
    856867    for(i=0;;i++){
    857868        if(basbuf[i]=='\0') break;
     869
     870        if( basbuf[i] == 1 && basbuf[i+1] == ESC_NAMESPACE ){
     871            for(i+=2,i2=0;;i2++,i++){
     872                if( IsCommandDelimitation( basbuf[i] ) ){
     873                    temporary[i2]=0;
     874                    break;
     875                }
     876                temporary[i2]=basbuf[i];
     877            }
     878            namespaceScopes.push_back( temporary );
     879
     880            continue;
     881        }
     882        else if( basbuf[i] == 1 && basbuf[i+1] == ESC_ENDNAMESPACE ){
     883            if( namespaceScopes.size() <= 0 ){
     884                SetError(12, "End Namespace", i );
     885            }
     886            else{
     887                namespaceScopes.pop_back();
     888            }
     889
     890            i += 2;
     891            continue;
     892        }
    858893
    859894        if(basbuf[i]==1&&(
     
    891926
    892927                //クラスを追加
    893                 CClass *pClass = pobj_DBClass->AddClass(temporary,nowLine);
     928                CClass *pClass = pobj_DBClass->AddClass(namespaceScopes, temporary,nowLine);
    894929                if( pClass ){
    895930                    if( basbuf[nowLine+1] == ESC_CLASS ){
  • BasicCompiler_Common/Class.h

    r100 r101  
    6161    friend CDBClass;
    6262    friend CDebugSection;
     63
     64    // 名前空間
     65    NamespaceScopes namespaceScopes;
    6366
    6467    //静的メンバ情報
     
    104107
    105108public:
    106     CClass(const char *name);
     109    CClass( const NamespaceScopes &namespaceScopes, const char *name );
    107110    ~CClass();
     111
     112    virtual const NamespaceScopes &GetNamespaceScopes() const
     113    {
     114        return namespaceScopes;
     115    }
     116
     117    bool IsEqualSymbol() const;
    108118
    109119    bool IsUsing() const;
     
    232242    CClass *check(const char *name);
    233243
    234     CClass *AddClass(const char *name,int nowLine);
     244    CClass *AddClass( const NamespaceScopes &namespaceScopes, const char *name,int nowLine);
    235245
    236246    void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);
  • BasicCompiler_Common/DebugMiddleFile.cpp

    r100 r101  
    486486    for(i3=0;i3<iMaxClassCount;i3++){
    487487        //クラス名
    488         pobj_DBClass->AddClass(buffer+i2,0);
     488        // TODO: 名前空間が未完成
     489        pobj_DBClass->AddClass(NamespaceScopes(),buffer+i2,0);
    489490        i2+=lstrlen(buffer+i2)+1;
    490491    }
  • BasicCompiler_Common/Procedure.cpp

    r100 r101  
    370370    return ( pMethod->bVirtual != 0 );
    371371}
    372 bool UserProc::EqualName( const string &name ) const
     372const NamespaceScopes &UserProc::GetNamespaceScopes() const
     373{
     374    if( !pParentClass ){
     375        SetError();
     376    }
     377    return pParentClass->GetNamespaceScopes();
     378}
     379bool UserProc::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const
    373380{
    374381    SetError();
    375     return true;
     382    return false;
    376383}
    377384
     
    503510    return true;
    504511}
    505 bool GlobalProc::EqualName( const string &name ) const
     512bool GlobalProc::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const
    506513{
    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    if( namespaceScopes.size() ){
     515        if( GetNamespaceScopes().IsCoverd( namespaceScopes ) ){
     516            if( GetName() == name ){
    514517                return true;
    515518            }
     
    519522        if( GetNamespaceScopes().size() ){
    520523            // 名前空間の判断が必要なとき
    521             if( !GetNamespaceScopes().IsUsing() ){
     524            if( !GetNamespaceScopes().IsUsing()
     525                && !GetNamespaceScopes().IsLiving() ){
    522526                // この名前空間は暗黙的に参照できないとき
    523527                return false;
    524528            }
    525529        }
    526         if( GetName() == name ){
    527             return true;
     530        else{
     531            if( GetName() == name ){
     532                return true;
     533            }
    528534        }
    529535    }
    530536
    531537    return false;
     538}
     539bool GlobalProc::IsEqualSymbol( const GlobalProc &globalProc ) const
     540{
     541    return IsEqualSymbol( globalProc.GetNamespaceScopes(), globalProc.GetName() );
     542}
     543bool GlobalProc::IsEqualSymbol( const string &fullName ) const
     544{
     545    char AreaName[VN_SIZE] = "";        //オブジェクト変数
     546    char NestName[VN_SIZE] = "";        //入れ子メンバ
     547    bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName );
     548
     549    return IsEqualSymbol( NamespaceScopes( AreaName ), NestName );
    532550}
    533551
  • BasicCompiler_Common/Procedure.h

    r100 r101  
    221221    }
    222222
     223    virtual const NamespaceScopes &GetNamespaceScopes() const;
     224    virtual bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;
     225
    223226    // ローカル変数
    224227    Variables localVars;
     
    249252        return *pCompilingUserProc;
    250253    }
    251 
    252     virtual bool EqualName( const string &name ) const;
    253254};
    254255
     
    270271    bool AddGlobalProc( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine );
    271272
    272     const NamespaceScopes &GetNamespaceScopes() const
     273    virtual const NamespaceScopes &GetNamespaceScopes() const
    273274    {
    274275        return namespaceScopes;
    275276    }
    276277
    277     virtual bool EqualName( const string &name ) const;
     278    virtual bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;
     279    virtual bool IsEqualSymbol( const GlobalProc &globalProc ) const;
     280    virtual bool IsEqualSymbol( const string &name ) const;
    278281};
    279282
  • BasicCompiler_Common/Subroutine.cpp

    r100 r101  
    618618            if(pobj_c==psi2->GetParentClassPtr()){
    619619                //重複エラーチェックを行う
    620                 if( pUserProc->GetName() == psi2->GetName() ){
     620                if( pUserProc->IsEqualSymbol( *psi2 ) ){
    621621                    if( Parameter::Equals( psi2->Params(), pUserProc->Params() ) ){
    622622                        SetError(15,pUserProc->GetName().c_str(),nowLine);
     
    661661
    662662    // 名前空間管理
    663     NamespaceScopes namespaceScopes;
     663    NamespaceScopes &namespaceScopes = Smoothie::Lexical::liveingNamespaceScopes;
     664    namespaceScopes.clear();
    664665
    665666    i=-1;
  • BasicCompiler_Common/hash.cpp

    r100 r101  
    6464    else lstrcpy(name,lpszName);
    6565
     66    if( (string)lpszName == "Test2.Proc3" ){
     67        int test=0;
     68    }
    6669
    6770    char ObjName[VN_SIZE];      //オブジェクト変数
     
    9295        }
    9396
    94         if( pobj_c ){
     97        if( pobj_c && pobj_c != (CClass *)-1 ){
    9598            if( isStatic ){
    9699                // 静的メソッドから列挙
     
    131134    while(pUserProc){
    132135        if(!pUserProc->GetParentClassPtr()){
    133             if( pUserProc->EqualName( name ) ){
     136            if( pUserProc->IsEqualSymbol( name ) ){
    134137                subs.push_back( pUserProc );
    135138            }
  • BasicCompiler_Common/include/Namespace.h

    r100 r101  
    1111public:
    1212    NamespaceScopes(){}
     13    NamespaceScopes( const char *name );
    1314    ~NamespaceScopes(){}
    1415
    15     void ToString( string &namespaceStr ) const
     16    string ToString() const
    1617    {
     18        string namespaceStr;
    1719        const vector<string> &me = *this;
    1820
     
    2830            namespaceStr += itemStr;
    2931        }
     32        return namespaceStr;
    3033    }
    3134
    32     bool Equal( const string &name ) const
     35    // 等しいかをチェック
     36    bool IsEqual( const string &name ) const
    3337    {
    34         string tempName;
    35         ToString( tempName );
    36         if( tempName == name ){
     38        if( ToString() == name ){
    3739            return true;
    3840        }
     
    4042    }
    4143
     44    // 等しいかをチェック
     45    bool IsEqual( const NamespaceScopes &namespaceScopes ) const
     46    {
     47        if( ToString() == namespaceScopes.ToString() ){
     48            return true;
     49        }
     50        return false;
     51    }
     52
     53    // 所属しているかをチェック
     54    // 例:
     55    // baseNamespaceScopes =  "Discoversoft"
     56    // entryNamespaceScopes = "Discoversoft.ActiveBasic"
     57    // この場合、entryNamespaceScopes は baseNamespaceScopes に所属している。
     58    static bool IsBelong( const NamespaceScopes &baseNamespaceScopes, const NamespaceScopes &entryNamespaceScopes )
     59    {
     60        if( baseNamespaceScopes.size() > entryNamespaceScopes.size() ){
     61            return false;
     62        }
     63
     64        for( int i=0; i<(int)baseNamespaceScopes.size(); i++ ){
     65            if( baseNamespaceScopes[i] != entryNamespaceScopes[i] ){
     66                return false;
     67            }
     68        }
     69        return true;
     70    }
     71
    4272    bool IsUsing() const
    4373    {
     74        // TODO: 実装
    4475        return false;
    4576    }
     77
     78    bool IsLiving() const;
     79
     80    // 包括しているかをチェック
     81    // 例:
     82    // this =   "Discoversoft.ActiveBasic"
     83    // living = "Discoversoft.ActiveBasic"
     84    // name =   "ActiveBasic"
     85    // この場合、living は name を包括している。
     86    bool IsCoverd( const string &name ) const;
     87    bool IsCoverd( const NamespaceScopes &namespaceScopes ) const;
    4688};
  • BasicCompiler_Common/include/Smoothie.h

    r100 r101  
    4040    public:
    4141        static BasicSource source;
     42        static NamespaceScopes liveingNamespaceScopes;
    4243    };
    4344
  • BasicCompiler_Common/src/Smoothie.cpp

    r91 r101  
    44
    55BasicSource Smoothie::Lexical::source;
     6NamespaceScopes Smoothie::Lexical::liveingNamespaceScopes;
    67
    78TypeDefCollection Smoothie::Meta::typeDefs;
  • ProjectEditor/SubOperation.cpp

    r85 r101  
    538538    }
    539539    else if(str[0]=='n'||str[0]=='N'){
     540        if(lstrcmpi(str,"Namespace")==0) return -1;
    540541        if(lstrcmpi(str,"Next")==0) return COM_NEXT;
    541542        if(lstrcmpi(str,"New")==0) return -1;
Note: See TracChangeset for help on using the changeset viewer.