Changeset 564 in dev


Ignore:
Timestamp:
May 5, 2008, 2:17:58 PM (16 years ago)
Author:
dai_9181
Message:

IsExistIsExistDuplicationKeyName
・キー名ではなく、インスタンスそのものの重複を発見するためのIsExistメソッドを実装。

Location:
trunk/ab5.0
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/BasicCompiler_Common/VariableOpe.cpp

    r561 r564  
    10501050
    10511051        //定数マクロとして定義されている場合は抜け出す
    1052         if( compiler.GetObjectModule().meta.GetGlobalConstMacros().IsExist( VarName ) )
     1052        if( compiler.GetObjectModule().meta.GetGlobalConstMacros().IsExistDuplicationKeyName( VarName ) )
    10531053        {
    10541054            return;
     
    10731073
    10741074    //定数マクロとして定義されている場合
    1075     if( compiler.GetObjectModule().meta.GetGlobalConstMacros().IsExist( VarName ) ){
     1075    if( compiler.GetObjectModule().meta.GetGlobalConstMacros().IsExistDuplicationKeyName( VarName ) ){
    10761076        compiler.errorMessenger.Output(15,VarName,cp);
    10771077        return;
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Class.h

    r562 r564  
    494494    }
    495495
    496     virtual CClass *Create( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name);
    497496    bool Insert( CClass *pClass, int nowLine );
    498497    CClass *Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine);
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Class.cpp

    r563 r564  
    646646
    647647    return false;
    648 }
    649 
    650 CClass *Classes::Create( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name){
    651     return new CClass(namespaceScopes, importedNamespaces, name);
    652 }
    653 bool Classes::Insert( CClass *pClass, int nowLine )
    654 {
    655     /////////////////////////////////
    656     // ハッシュデータに追加
    657     /////////////////////////////////
    658 
    659     if( !Put( pClass ) )
    660     {
    661         compiler.errorMessenger.Output(15,pClass->GetName(), nowLine);
    662         return false;
    663     }
    664     return true;
    665 }
    666 CClass *Classes::Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine){
    667     //////////////////////////////////////////////////////////////////////////
    668     // クラスを追加
    669     // ※名前のみを登録。その他の情報はSetClassメソッドで!
    670     //////////////////////////////////////////////////////////////////////////
    671 
    672     CClass *pClass = Create(namespaceScopes, importedNamespaces, name);
    673 
    674     if( !Insert( pClass, nowLine ) )
    675     {
    676         return NULL;
    677     }
    678 
    679     return pClass; 
    680648}
    681649
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Class.cpp

    r561 r564  
    121121
    122122            //クラスを追加
    123             CClass *pClass = classes.Add(namespaceScopes, importedNamespaces, temporary,nowLine);
    124             if( pClass ){
    125                 if( source[nowLine+1] == ESC_CLASS ){
    126                     if( isEnum )
    127                     {
    128                         pClass->SetClassType( CClass::Enum );
    129                     }
    130                     else if( isDelegate )
    131                     {
    132                         pClass->SetClassType( CClass::Delegate );
    133                     }
    134                     else{
    135                         pClass->SetClassType( CClass::Class );
    136                     }
    137                 }
    138                 else if( source[nowLine+1] == ESC_INTERFACE ){
    139                     pClass->SetClassType( CClass::Interface );
     123            CClass *pClass = new CClass( namespaceScopes, importedNamespaces, temporary );
     124            if( classes.IsExist( pClass ) )
     125            {
     126                // 既に存在している
     127                compiler.errorMessenger.Output(15,pClass->GetName(), nowLine);
     128
     129                delete pClass;
     130
     131                continue;
     132            }
     133
     134            classes.Put( pClass );
     135
     136            if( source[nowLine+1] == ESC_CLASS )
     137            {
     138                if( isEnum )
     139                {
     140                    pClass->SetClassType( CClass::Enum );
     141                }
     142                else if( isDelegate )
     143                {
     144                    pClass->SetClassType( CClass::Delegate );
    140145                }
    141146                else{
    142                     pClass->SetClassType( CClass::Structure );
    143                 }
     147                    pClass->SetClassType( CClass::Class );
     148                }
     149            }
     150            else if( source[nowLine+1] == ESC_INTERFACE )
     151            {
     152                pClass->SetClassType( CClass::Interface );
     153            }
     154            else
     155            {
     156                pClass->SetClassType( CClass::Structure );
    144157            }
    145158
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Const.cpp

    r543 r564  
    162162
    163163                //重複チェック
    164                 if( compiler.GetObjectModule().meta.GetGlobalConstMacros().IsExist( name )
    165                     || compiler.GetObjectModule().meta.GetGlobalConsts().IsExist( name ) )
     164                if( compiler.GetObjectModule().meta.GetGlobalConstMacros().IsExistDuplicationKeyName( name )
     165                    || compiler.GetObjectModule().meta.GetGlobalConsts().IsExistDuplicationKeyName( name ) )
    166166                {
    167167                    compiler.errorMessenger.Output(15,name,cp);
  • trunk/ab5.0/abdev/compiler_x86/Compile_Calc.cpp

    r523 r564  
    461461            }
    462462            else{
    463                 if( compiler.GetObjectModule().meta.GetGlobalConsts().IsExist(variable)
    464                     || compiler.GetObjectModule().meta.GetGlobalConstMacros().IsExist(variable) )
     463                if( compiler.GetObjectModule().meta.GetGlobalConsts().IsExistDuplicationKeyName(variable)
     464                    || compiler.GetObjectModule().meta.GetGlobalConstMacros().IsExistDuplicationKeyName(variable) )
    465465                {
    466466                    //定数リストに該当したとき
  • trunk/ab5.0/jenga/include/common/Hashmap.h

    r520 r564  
    8686    }
    8787
    88     bool IsExist( const std::string &keyName ) const
     88    bool IsExistDuplicationKeyName( const std::string &keyName ) const
    8989    {
    9090        int key = GetHash( keyName.c_str() );
    9191
    9292        if(hashArray[key]){
    93             T *temp = hashArray[key];
     93            const T *temp = hashArray[key];
    9494            while( true ){
    9595                if( temp->IsDuplication( keyName ) )
     96                {
     97                    // 重複している
     98                    return true;
     99                }
     100
     101                if( temp->GetChainNext() == NULL )
     102                {
     103                    break;
     104                }
     105                temp = temp->GetChainNext();
     106            }
     107        }
     108
     109        return false;
     110    }
     111
     112    bool IsExist( const T* value ) const
     113    {
     114        int key = GetHash( value->GetKeyName().c_str() );
     115
     116        if(hashArray[key]){
     117            const T *temp = hashArray[key];
     118            while( true ){
     119                if( temp->IsDuplication( value ) )
    96120                {
    97121                    // 重複している
Note: See TracChangeset for help on using the changeset viewer.