Ignore:
Timestamp:
Mar 10, 2008, 5:39:36 PM (16 years ago)
Author:
dai_9181
Message:

・ジェネリックな型をパラメータに持つメソッドのオーバーロード解決に対応した。
・型パラメータの制約クラス指定に対応した。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abdev/BasicCompiler_Common/src/Type.cpp

    r378 r424  
    541541void ResolveFormalGenericTypeParameter( Type &typeParameter, const Type &classType, const UserProc *pUserProc )
    542542{
     543    if( !typeParameter.IsTypeParameter() )
     544    {
     545        // ジェネリックな型ではなかったとき
     546        return;
     547    }
     548
    543549    /////////////////////////////////////////////////////////
    544550    // ☆★☆ ジェネリクスサポート ☆★☆
    545551
     552    // ポインタレベルを抽出
     553    int ptrLevel = PTR_LEVEL( typeParameter.GetBasicType() );
     554
     555    if( pUserProc )
     556    {
     557        if( classType.IsObject() )
     558        {
     559            // 基底クラスでの自己解決
     560            const CClass *pClass = &classType.GetClass();
     561            while( pClass->HasSuperClass() )
     562            {
     563                if( pUserProc->GetParentClassPtr() == &pClass->GetSuperClass() )
     564                {
     565                    if( pClass->GetSuperClassActualTypeParameters().size() )
     566                    {
     567                        // TODO: 適切な形に実装し直す(暫定的にトップの型を持ってきている)
     568                        typeParameter = pClass->GetSuperClassActualTypeParameters()[0];
     569                    }
     570                }
     571                pClass = &pClass->GetSuperClass();
     572            }
     573        }
     574    }
     575
    546576    if( typeParameter.IsTypeParameter() )
    547577    {
    548         // 型パラメータだったとき
    549 
    550         // ポインタレベルを抽出
    551         int ptrLevel = PTR_LEVEL( typeParameter.GetBasicType() );
    552 
    553         if( pUserProc )
     578        if( classType.HasActualGenericType() )
    554579        {
    555             if( classType.IsObject() )
    556             {
    557                 // 基底クラスでの自己解決
    558                 const CClass *pClass = &classType.GetClass();
    559                 while( pClass->HasSuperClass() )
    560                 {
    561                     if( pUserProc->GetParentClassPtr() == &pClass->GetSuperClass() )
    562                     {
    563                         if( pClass->GetSuperClassActualTypeParameters().size() )
    564                         {
    565                             // TODO: 適切な形に実装し直す(暫定的にトップの型を持ってきている)
    566                             typeParameter = pClass->GetSuperClassActualTypeParameters()[0];
    567                         }
    568                     }
    569                     pClass = &pClass->GetSuperClass();
    570                 }
    571             }
    572         }
    573 
    574         if( typeParameter.IsTypeParameter() )
     580            typeParameter = classType.GetActualGenericType( typeParameter.GetFormalTypeIndex() );
     581        }
     582        else
    575583        {
    576             if( classType.HasActualGenericType() )
    577             {
    578                 typeParameter = classType.GetActualGenericType( typeParameter.GetFormalTypeIndex() );
    579             }
    580             else
    581             {
    582                 // TODO: ベースオブジェクト(指定されていないときはObjectクラス)にセットする
    583                 typeParameter.SetBasicType( DEF_OBJECT );
    584             }
    585         }
    586 
    587         for( int i=0; i<ptrLevel; i++ )
    588         {
    589             typeParameter.PtrLevelUp();
    590         }
     584            // 制約クラス(指定されていないときはObjectクラス)にセットする
     585            typeParameter.SetBasicType( DEF_OBJECT );
     586        }
     587    }
     588
     589    for( int i=0; i<ptrLevel; i++ )
     590    {
     591        typeParameter.PtrLevelUp();
    591592    }
    592593
Note: See TracChangeset for help on using the changeset viewer.