Changeset 447 in dev for trunk/ab5.0


Ignore:
Timestamp:
Mar 21, 2008, 2:23:20 PM (16 years ago)
Author:
dai_9181
Message:

共変戻り値のオーバーロードをサポートした。

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

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Type.h

    r424 r447  
    153153
    154154    bool Equals( const Type &type ) const;
     155    bool IsCovariant( const Type &type ) const;
    155156
    156157    int GetBasicSize() const;
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Class.cpp

    r431 r447  
    130130
    131131//自身の派生クラスかどうかを確認
    132 bool CClass::IsSubClass( const CClass *pClass ) const
    133 {
    134     if( !pClass->HasSuperClass() )
     132bool CClass::IsSubClass( const CClass *pSubClass ) const
     133{
     134    if( !pSubClass->HasSuperClass() )
    135135    {
    136136        return false;
    137137    }
    138138
    139     const CClass *pTempClass = &pClass->GetSuperClass();
     139    const CClass *pTempClass = &pSubClass->GetSuperClass();
    140140    while( pTempClass ){
    141141        if( this == pTempClass ) return true;
     
    146146
    147147//自身と等しいまたは派生クラスかどうかを確認
    148 bool CClass::IsEqualsOrSubClass( const CClass *pClass ) const
    149 {
    150     if( IsEquals( pClass ) ) return true;
    151     return IsSubClass( pClass );
     148bool CClass::IsEqualsOrSubClass( const CClass *pSubClass ) const
     149{
     150    if( IsEquals( pSubClass ) ) return true;
     151    return IsSubClass( pSubClass );
    152152}
    153153
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Procedure.cpp

    r438 r447  
    2626            return true;
    2727        }
    28 
    29         if( this->returnType.IsTypeParameter() )
     28        else if( this->returnType.IsCovariant( pUserProc->returnType ) )
     29        {
     30            // 戻り値が共変
     31            return true;
     32        }
     33        else if( this->returnType.IsTypeParameter() )
    3034        {
    3135            // 型パラメータだったとき
     36
    3237            if( actualTypeParametersForThisProc[this->returnType.GetFormalTypeIndex()].Equals( pUserProc->returnType ) )
    3338            {
    3439                // 戻り値が等しい
     40                return true;
     41            }
     42            else if( actualTypeParametersForThisProc[this->returnType.GetFormalTypeIndex()].IsCovariant( pUserProc->returnType ) )
     43            {
     44                // 戻り値が共変
    3545                return true;
    3646            }
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Type.cpp

    r424 r447  
    150150    }
    151151    return false;
     152}
     153
     154bool Type::IsCovariant( const Type &type ) const
     155{
     156    if( !this->IsObject() || !type.IsObject() )
     157    {
     158        // 共変性の判別はクラス型のみ
     159        return false;
     160    }
     161
     162    return this->GetClass().IsSubClass( &type.GetClass() );
    152163}
    153164
Note: See TracChangeset for help on using the changeset viewer.