Changeset 105 in dev


Ignore:
Timestamp:
May 4, 2007, 3:43:48 PM (17 years ago)
Author:
dai_9181
Message:

名前空間収集モジュール(NamespaceScopesCollectionクラス)を追加。

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler32/MakePeHdr.cpp

    r103 r105  
    159159    //関数ポインタ情報を初期化
    160160    Smoothie::Meta::procPointers.clear();
     161
     162    // 名前空間情報を取得
     163    NamespaceScopesCollection::CollectNamespaces(
     164        Smoothie::Lexical::source.GetBuffer(),
     165        Smoothie::Meta::namespaceScopesCollection
     166    );
    161167
    162168    //クラス名を取得(詳細情報はGetAllClassInfoで取得)
  • BasicCompiler64/MakePeHdr.cpp

    r103 r105  
    144144    //関数ポインタ情報を初期化
    145145    Smoothie::Meta::procPointers.clear();
     146
     147    // 名前空間情報を取得
     148    NamespaceScopesCollection::CollectNamespaces(
     149        Smoothie::Lexical::source.GetBuffer(),
     150        Smoothie::Meta::namespaceScopesCollection
     151    );
    146152
    147153    //クラス名を取得(詳細情報はGetAllClassInfoで取得)
  • BasicCompiler_Common/include/Namespace.h

    r102 r105  
    1111public:
    1212    NamespaceScopes(){}
    13     NamespaceScopes( const char *name );
     13    NamespaceScopes( const string &namespaceStr );
    1414    ~NamespaceScopes(){}
    1515
     
    114114    }
    115115};
     116
     117class NamespaceScopesCollection : public vector<NamespaceScopes>
     118{
     119public:
     120    bool IsExist( const NamespaceScopes &namespaceScopes ) const
     121    {
     122        const NamespaceScopesCollection &namespaceScopesCollection = *this;
     123        BOOST_FOREACH( const NamespaceScopes &tempNamespaceScopes, namespaceScopesCollection ){
     124            if( tempNamespaceScopes.IsEqual( namespaceScopes ) ){
     125                return true;
     126            }
     127        }
     128        return false;
     129    }
     130    bool IsExist( const string &namespaceStr ) const
     131    {
     132        return IsExist( NamespaceScopes( namespaceStr ) );
     133    }
     134    void SplitNamespace( const char *fullName, char *namespaceStr, char *simpleName ) const;
     135
     136    static bool CollectNamespaces( const char *source, NamespaceScopesCollection &namespaceScopesCollection );
     137};
  • BasicCompiler_Common/include/Smoothie.h

    r101 r105  
    4848        static TypeDefCollection typeDefs;
    4949        static vector<ProcPointer *> procPointers;
     50        static NamespaceScopesCollection namespaceScopesCollection;
    5051    };
    5152};
  • BasicCompiler_Common/src/Namespace.cpp

    r101 r105  
    22
    33
    4 NamespaceScopes::NamespaceScopes( const char *namespaceStr ){
     4NamespaceScopes::NamespaceScopes( const string &namespaceStr ){
    55    int i = 0;
    6     while( namespaceStr[i] ){
     6    while( i < (int)namespaceStr.size() ){
    77        char temporary[VN_SIZE];
    88        for( int i2=0; ; i2++, i++ ){
     
    6161    return IsCoverd( namespaceScopes.ToString() );
    6262}
     63
     64
     65void NamespaceScopesCollection::SplitNamespace( const char *fullName, char *namespaceStr, char *simpleName ) const
     66{
     67    NamespaceScopes namespaceScopes( fullName );
     68    bool hasSimpleName = false;
     69    while( namespaceScopes.size() > 0 ){
     70        if( IsExist( namespaceScopes ) ){
     71            break;
     72        }
     73        namespaceScopes.pop_back();
     74
     75        hasSimpleName = true;
     76    }
     77
     78    lstrcpy( namespaceStr, namespaceScopes.ToString().c_str() );
     79
     80    bool hasNamespace = false;
     81    if( namespaceStr[0] ){
     82        hasNamespace = true;
     83    }
     84
     85    int dotLength = 0;
     86    if( hasSimpleName && hasNamespace ){
     87        dotLength = 1;
     88    }
     89
     90    lstrcpy( simpleName, fullName + lstrlen( namespaceStr ) + dotLength );
     91}
     92bool NamespaceScopesCollection::CollectNamespaces( const char *source, NamespaceScopesCollection &namespaceScopesCollection )
     93{
     94    int i, i2;
     95    char temporary[VN_SIZE];
     96
     97    bool isSuccessful = true;
     98
     99    // 名前空間管理
     100    NamespaceScopes namespaceScopes;
     101
     102    for(i=0;;i++){
     103        if(source[i]=='\0') break;
     104
     105        if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){
     106            for(i+=2,i2=0;;i2++,i++){
     107                if( IsCommandDelimitation( source[i] ) ){
     108                    temporary[i2]=0;
     109                    break;
     110                }
     111                temporary[i2]=source[i];
     112            }
     113            namespaceScopes.push_back( temporary );
     114
     115            if( !namespaceScopesCollection.IsExist( namespaceScopes ) ){
     116                namespaceScopesCollection.push_back( namespaceScopes );
     117            }
     118
     119            continue;
     120        }
     121        else if( source[i] == 1 && source[i+1] == ESC_ENDNAMESPACE ){
     122            if( namespaceScopes.size() <= 0 ){
     123                SetError(12, "End Namespace", i );
     124                isSuccessful = false;
     125            }
     126            else{
     127                namespaceScopes.pop_back();
     128            }
     129
     130            i += 2;
     131            continue;
     132        }
     133    }
     134
     135    if( namespaceScopes.size() > 0 ){
     136        SetError(63,NULL,-1);
     137        isSuccessful = false;
     138    }
     139
     140    return isSuccessful;
     141}
  • BasicCompiler_Common/src/Smoothie.cpp

    r101 r105  
    88TypeDefCollection Smoothie::Meta::typeDefs;
    99vector<ProcPointer *> Smoothie::Meta::procPointers;
     10NamespaceScopesCollection Smoothie::Meta::namespaceScopesCollection;
Note: See TracChangeset for help on using the changeset viewer.