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

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

Location:
trunk/ab5.0/abdev/BasicCompiler_Common/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • 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.