Changeset 448 in dev


Ignore:
Timestamp:
Mar 21, 2008, 7:34:57 PM (16 years ago)
Author:
dai_9181
Message:

・デリゲートの共変戻り値、反変引数に対応した。
・core.libで定義されたデリゲートがアプリケーションプロジェクトで利用できないバグを修正。

Location:
trunk/ab5.0/abdev
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/BasicCompiler32/OperatorProc.cpp

    r435 r448  
    8282            *pUserProc->Params()[i],
    8383            *params[i],
    84             "",
     84            NULL,
    8585            i);
    8686    }
  • trunk/ab5.0/abdev/BasicCompiler64/OperatorProc.cpp

    r436 r448  
    8888            *pUserProc->Params()[i],
    8989            *params[i],
    90             "",
     90            NULL,
    9191            i);
    9292    }
  • trunk/ab5.0/abdev/BasicCompiler_Common/error.cpp

    r424 r448  
    470470        }
    471471
    472         if( !varType.GetClass().IsEqualsOrSubClass( &calcType.GetClass() ) )
    473         {
    474             //等しくなく、派生クラスでもないとき
    475             DifferentTypeError( varType, calcType,3,pszFuncName,ParmNum);
    476             return false;
     472        if( varType.IsDelegate() && calcType.IsDelegate() )
     473        {
     474            // デリゲート同士の比較の場合
     475            // ※共変戻り値及び反辺引数をサポートすること
     476            if( !varType.GetClass().GetDelegate().IsSimilar( calcType.GetClass().GetDelegate() ) )
     477            {
     478                // 等しいと見なされないとき
     479                DifferentTypeError( varType, calcType,3,pszFuncName,ParmNum);
     480                return false;
     481            }
     482        }
     483        else
     484        {
     485            // 一般的なクラスの比較の場合
     486
     487            if( !varType.GetClass().IsEqualsOrSubClass( &calcType.GetClass() ) )
     488            {
     489                //等しくなく、派生クラスでもないとき
     490                DifferentTypeError( varType, calcType,3,pszFuncName,ParmNum);
     491                return false;
     492            }
    477493        }
    478494    }
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Delegate.h

    r422 r448  
    5252        return dynamicParams;
    5353    }
     54
     55    /*!
     56    @brief  オーバーライド用にデリゲート同士が等しいかどうかをチェックする
     57    @param  dgt 照らし合わせるデリゲート
     58    */
     59    bool IsSimilar( const Delegate &dgt ) const;
    5460};
    5561
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Parameter.h

    r402 r448  
    8484    }
    8585
    86     bool Equals( const Parameter &param ) const;
    87     bool Equals( const Types &actualTypeParametersForThisProc, const Parameter &param ) const;
     86    bool Equals( const Parameter &param, bool isContravariant ) const;
     87    bool Equals( const Types &actualTypeParametersForThisProc, const Parameter &param, bool isContravariant ) const;
    8888};
    8989
     
    102102public:
    103103
    104     bool Equals( const Parameters &params ) const;
    105     bool Equals( const Types &actualTypeParametersForThisProc, const Parameters &params ) const;
     104    bool Equals( const Parameters &params, bool isContravariant = false ) const;
     105    bool Equals( const Types &actualTypeParametersForThisProc, const Parameters &params, bool isContravariant = false ) const;
    106106
    107107    int GetMemorySize() const
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Type.h

    r447 r448  
    154154    bool Equals( const Type &type ) const;
    155155    bool IsCovariant( const Type &type ) const;
     156    bool IsContravariant( const Type &type ) const;
    156157
    157158    int GetBasicSize() const;
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Delegate.cpp

    r422 r448  
    2020        }
    2121    }
     22}
     23
     24bool Delegate::IsSimilar( const Delegate &dgt ) const
     25{
     26    if( this->Params().Equals( dgt.Params(), true ) )           // パラメータが等しい、もしくは反変
     27    {
     28        if( this->returnType.Equals( dgt.returnType ) )
     29        {
     30            // 戻り値が等しい
     31            return true;
     32        }
     33        else if( this->returnType.IsCovariant( dgt.returnType ) )
     34        {
     35            // 戻り値が共変
     36            return true;
     37        }
     38    }
     39    return false;
    2240}
    2341
     
    149167        const Delegate &dg = *this->Iterator_GetNext();
    150168
     169        if( !dg.isTargetObjectModule )
     170        {
     171            // 静的リンクライブラリの場合は飛ばす(既にインスタンスが定義済みであるため)
     172            continue;
     173        }
     174
    151175        std::map<std::string,std::string> values;
    152176
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Meta.cpp

    r392 r448  
    152152    }
    153153    meta.procPointers.PullOutAll();
     154
     155    // デリゲート
     156    meta.GetDelegates().Iterator_Reset();
     157    while( meta.GetDelegates().Iterator_HasNext() )
     158    {
     159        Delegate *pDelegate = meta.GetDelegates().Iterator_GetNext();
     160        pDelegate->isTargetObjectModule = false;
     161        this->GetDelegates().Put( pDelegate );
     162    }
     163    meta.GetDelegates().PullOutAll();
    154164}
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Parameter.cpp

    r422 r448  
    22
    33
    4 bool Parameter::Equals( const Parameter &param ) const
     4bool Parameter::Equals( const Parameter &param, bool isContravariant ) const
    55{
    66    if( Type::Equals( param ) )
     
    2525    }
    2626
     27    if( isContravariant )
     28    {
     29        // 反変引数を許可する
     30        if( this->IsContravariant( param ) )
     31        {
     32            // 反変引数だったとき
     33            return true;
     34        }
     35    }
     36
    2737    return false;
    2838}
    29 bool Parameter::Equals( const Types &actualTypeParametersForThisProc, const Parameter &param ) const
    30 {
    31     if( Equals( param ) )
     39bool Parameter::Equals( const Types &actualTypeParametersForThisProc, const Parameter &param, bool isContravariant ) const
     40{
     41    if( Equals( param, isContravariant ) )
    3242    {
    3343        return true;
     
    4757}
    4858
    49 bool Parameters::Equals( const Parameters &params ) const
     59bool Parameters::Equals( const Parameters &params, bool isContravariant ) const
    5060{
    5161    if( this->size() != params.size() ){
     
    5565    int max = (int)this->size();
    5666    for( int i=0; i<max; i++ ){
    57         if( !(*this)[i]->Equals( *params[i] ) ){
     67        if( !(*this)[i]->Equals( *params[i], isContravariant ) ){
    5868            return false;
    5969        }
     
    6272    return true;
    6373}
    64 bool Parameters::Equals( const Types &actualTypeParametersForThisProc, const Parameters &params ) const
     74bool Parameters::Equals( const Types &actualTypeParametersForThisProc, const Parameters &params, bool isContravariant ) const
    6575{
    6676    if( this->size() != params.size() ){
     
    7080    int max = (int)this->size();
    7181    for( int i=0; i<max; i++ ){
    72         if( !(*this)[i]->Equals( actualTypeParametersForThisProc, *params[i] ) ){
     82        if( !(*this)[i]->Equals( actualTypeParametersForThisProc, *params[i], isContravariant ) ){
    7383            return false;
    7484        }
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Type.cpp

    r447 r448  
    161161
    162162    return this->GetClass().IsSubClass( &type.GetClass() );
     163}
     164bool Type::IsContravariant( const Type &type ) const
     165{
     166    if( !this->IsObject() || !type.IsObject() )
     167    {
     168        // 反変性の判別はクラス型のみ
     169        return false;
     170    }
     171
     172    return type.GetClass().IsSubClass( &this->GetClass() );
    163173}
    164174
Note: See TracChangeset for help on using the changeset viewer.