Changeset 424 in dev for trunk


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

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

Location:
trunk/abdev
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/abdev/BasicCompiler32/Compile_Func.cpp

    r370 r424  
    452452
    453453        //オーバーロードを解決
    454         pUserProc=OverloadSolution( name, subs, *pBaseParams, Type() );
     454        pUserProc=OverloadSolution( name, subs, *pBaseParams, Type(), Type() );
    455455
    456456        if( isCallOn && baseType.IsDelegate() )
  • trunk/abdev/BasicCompiler32/Compile_Statement.cpp

    r415 r424  
    10221022
    10231023                        //オーバーロードを解決
    1024                         const UserProc *pUserProc = OverloadSolution("==",subs, params, NULL);
     1024                        const UserProc *pUserProc = OverloadSolution( "==", subs, params, Type( DEF_BOOLEAN ), type1 );
    10251025
    10261026                        delete params[0];
  • trunk/abdev/BasicCompiler32/Compile_Var.cpp

    r421 r424  
    428428                int ptrLevel = PTR_LEVEL( resultType.GetBasicType() );
    429429
    430                 // TODO: ベースオブジェクト(指定されていないときはObjectクラス)にセットする
     430                // 制約クラス(指定されていないときはObjectクラス)にセットする
    431431                resultType.SetBasicType( DEF_OBJECT );
    432432
  • trunk/abdev/BasicCompiler32/Opcode.h

    r415 r424  
    190190
    191191private:
    192     bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType, bool &isErrored );
     192    bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType, const Type &leftType, const UserProc &userProc, bool &isErrored );
    193193public:
    194     const UserProc *_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false );
    195     const UserProc *OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false );
     194    const UserProc *_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, const Type &leftType, bool isEnabledReturnType );
     195    const UserProc *OverloadSolution( const char *name, std::vector<const UserProc *> &subs, const Type &leftType, bool isEnabledReturnType = false );
    196196
    197197    void ApplyDefaultParameters( const Parameters &params );
  • trunk/abdev/BasicCompiler32/OperatorProc.cpp

    r402 r424  
    6060    if(idCalc==CALC_EQUAL) lstrcpy(temporary,"==");
    6161    else GetCalcName(idCalc,temporary);
    62     const UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType );
     62    const UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType, leftType );
    6363
    6464    if(!pUserProc){
  • trunk/abdev/BasicCompiler_Common/Compile.cpp

    r402 r424  
    8484// ジェネリクスのクラス型記述を分析
    8585///////////////////////////////////////////////////
    86 void SplitGenericClassInstance( const char *fullName, char *className, Jenga::Common::Strings &typeParameters )
     86void SplitGenericClassInstance( const char *fullName, char *className, Jenga::Common::Strings &typeParameters, bool isDefiningClass, Jenga::Common::Strings *pTypeParameterBaseClassNames )
    8787{
     88    if( isDefiningClass )
     89    {
     90        if( !pTypeParameterBaseClassNames )
     91        {
     92            SetError();
     93        }
     94        pTypeParameterBaseClassNames->clear();
     95    }
     96
    8897    int i = 0;
    8998    typeParameters.clear();
     
    109118                SetError(1,NULL,cp);
    110119            }
    111 
    112120            typeParameters.push_back( temporary );
     121
     122            if( isDefiningClass )
     123            {
     124                // クラス定義中にこの関数が呼び出されたとき
     125
     126                if( fullName[i] == 1 && fullName[i+1] == ESC_AS )
     127                {
     128                    // 型パラメータの制約クラスを取得
     129                    i += 2;
     130                    GetIdentifierToken( temporary, fullName, i );
     131                    if( temporary[0] == '\0' )
     132                    {
     133                        extern int cp;
     134                        SetError(1,NULL,cp);
     135                    }
     136                }
     137                else
     138                {
     139                    temporary[0] = 0;
     140                }
     141                pTypeParameterBaseClassNames->push_back( temporary );
     142            }
    113143
    114144            if( fullName[i] == ',' )
  • trunk/abdev/BasicCompiler_Common/NumOpe_GetType.cpp

    r415 r424  
    194194}
    195195
    196 int GetReturnType_OperatorProc(int idCalc,const Type &baseType,int *type,LONG_PTR *index_stack,int &sp){
    197     //オーバーロードされたオペレータ関数の戻り値を取得
    198     CClass *pobj_c;
    199     pobj_c=(CClass *)index_stack[sp-2];
     196int GetReturnType_OperatorProc(int idCalc,const Type &baseType,int *type_stack,LONG_PTR *index_stack,int &sp){
     197    Type leftType( type_stack[sp-2], index_stack[sp-2] );
     198    Type rightType( type_stack[sp-1] & (~FLAG_CAST), index_stack[sp-1] );
     199
     200    //オーバーロードされたオペレータ関数を呼び出す
     201    const CClass *pobj_c = &leftType.GetClass();
    200202
    201203    std::vector<const UserProc *> subs;
     
    221223
    222224    if(bTwoTerm){
    223         params.push_back( new Parameter( "", Type( type[sp-1], index_stack[sp-1] ) ) );
     225        params.push_back( new Parameter( "", rightType ) );
    224226    }
    225227
     
    229231    if(idCalc==CALC_EQUAL) lstrcpy(temporary,"==");
    230232    else GetCalcName(idCalc,temporary);
    231     const UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType );
     233    const UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType, leftType );
    232234
    233235    if(bTwoTerm){
     
    246248
    247249    sp--;
    248     type[sp-1]=pUserProc->ReturnType().GetBasicType();
     250    type_stack[sp-1]=pUserProc->ReturnType().GetBasicType();
    249251    index_stack[sp-1]=pUserProc->ReturnType().GetIndex();
    250252
  • trunk/abdev/BasicCompiler_Common/Overload.cpp

    r206 r424  
    2929        char MethodName[VN_SIZE];
    3030        if( !SplitMemberName( name, NULL, MethodName ) ) lstrcpy( MethodName, name );
     31
    3132/*
    3233        //メソッドの場合は静的かどうかを調べる
     
    4041        pobj_parameter=new ParamImpl(Parameter);
    4142
     43        Type leftType;
     44        GetTermType( ObjectName, leftType );
    4245
    43         const UserProc *pUserProc = pobj_parameter->OverloadSolution(name,subs);
     46        const UserProc *pUserProc = pobj_parameter->OverloadSolution( name, subs, leftType );
    4447
    4548
     
    5457    std::vector<const UserProc *> &subs,
    5558    const Parameters &params,
    56     const Type &returnType ){
     59    const Type &returnType,
     60    const Type &leftType )
     61{
    5762
    5863        // オーバーロードの解決
     
    6772        }
    6873
    69         const UserProc *pUserProc = pobj_Parameter->OverloadSolution(name,subs);
     74        const UserProc *pUserProc = pobj_Parameter->OverloadSolution( name, subs, leftType);
    7075
    7176        delete pobj_Parameter;
  • trunk/abdev/BasicCompiler_Common/ParamImpl.cpp

    r364 r424  
    107107}
    108108
    109 bool ParamImpl::EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType, bool &isErrored ){
     109bool ParamImpl::EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType, const Type &leftType, const UserProc &userProc, bool &isErrored ){
    110110    //パラメータを識別してオーバーロードを解決
    111111
     
    124124    for(int i=0;i<max;i++){
    125125        Parameter &param = *targetParms[i];
     126
     127        Type paramType( param );
     128        ResolveFormalGenericTypeParameter( paramType, leftType, &userProc );
    126129
    127130        if( i >= ParmsNum ){
     
    140143
    141144            if( !NumOpe_GetType(Parms[i],
    142                 ( level <= OVERLOAD_LEVEL3 )? nullParam : param,
     145                ( level <= OVERLOAD_LEVEL3 )? nullParam : paramType,
    143146                argType) )
    144147            {
     
    151154        }
    152155
    153         if(argType.GetBasicType()!=param.GetBasicType()){
     156        if( ( argType.IsObject() && paramType.IsObject() ) || argType.GetBasicType() == paramType.GetBasicType() )
     157        {
     158            if( argType.IsStruct() ){
     159                if(argType.GetIndex()!=paramType.GetIndex()){
     160                    return false;
     161                }
     162            }
     163            else if( argType.IsObject() ){
     164                if( level == OVERLOAD_LEVEL0 ){
     165                    if( !paramType.GetClass().IsEquals( &argType.GetClass() ) ){
     166                        return false;
     167                    }
     168                }
     169                else{
     170                    if( !paramType.GetClass().IsEqualsOrSubClass( &argType.GetClass() ) ){
     171                        return false;
     172                    }
     173                }
     174            }
     175        }
     176        else
     177        {
    154178            if( level == OVERLOAD_LEVEL0 || level == OVERLOAD_LEVEL1 || level==OVERLOAD_LEVEL4 ){
    155179                return false;
    156180            }
    157181            else if( level == OVERLOAD_LEVEL2 ){
    158                 if( !(argType.IsWhole() && param.IsWhole() && argType.GetBasicSize() == param.GetBasicSize() ) ){
     182                if( !(argType.IsWhole() && paramType.IsWhole() && argType.GetBasicSize() == paramType.GetBasicSize() ) ){
    159183                    // サイズ違い
    160184                    return false;
     
    163187            else if( level == OVERLOAD_LEVEL3 || level==OVERLOAD_LEVEL5){
    164188                if(!(
    165                     argType.IsWhole()&&param.IsWhole()||
    166                     argType.IsReal()&&param.IsReal()
     189                    argType.IsWhole()&&paramType.IsWhole()||
     190                    argType.IsReal()&&paramType.IsReal()
    167191                    )){
    168192                        return false;
    169193                }
    170                 if( argType.IsPointer() || param.IsPointer() )
     194                if( argType.IsPointer() || paramType.IsPointer() )
    171195                {
    172196                    // ポインタ型の不整合は認めない
     
    175199            }
    176200            else if(level==OVERLOAD_LEVEL6){
    177                 if(argType.IsObject()||param.IsObject()) return false;
    178             }
    179         }
    180         else{
    181             if( NATURAL_TYPE(argType.GetBasicType())==DEF_STRUCT){
    182                 if(argType.GetIndex()!=param.GetIndex()){
    183                     return false;
    184                 }
    185             }
    186             else if( NATURAL_TYPE(argType.GetBasicType())==DEF_OBJECT ){
    187                 if( level == OVERLOAD_LEVEL0 ){
    188                     if( !param.GetClass().IsEquals( &argType.GetClass() ) ){
    189                         return false;
    190                     }
    191                 }
    192                 else{
    193                     if( !param.GetClass().IsEqualsOrSubClass( &argType.GetClass() ) ){
    194                         return false;
    195                     }
    196                 }
     201                if(argType.IsObject()||paramType.IsObject()) return false;
    197202            }
    198203        }
     
    209214}
    210215
    211 const UserProc *ParamImpl::_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType ){
     216const UserProc *ParamImpl::_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, const Type &leftType, bool isEnabledReturnType ){
    212217    const UserProc *pUserProc = NULL;
    213218
     
    218223            bool isErrored = false;
    219224            bool isHit = false;
    220             isHit = EvaluateOverloadScore( level, pTempUserProc->Params(), isEnabledReturnType?pTempUserProc->ReturnType():Type(), isErrored );
     225            isHit = EvaluateOverloadScore( level, pTempUserProc->Params(), isEnabledReturnType?pTempUserProc->ReturnType():Type(), leftType, *pTempUserProc, isErrored );
    221226            if( isErrored )
    222227            {
     
    239244                        trace_for_overload( "戻り値も比較するモードに切り替えてオーバーロード解決を試みる" );
    240245
    241                         return OverloadSolution(name,subs, true);
     246                        return OverloadSolution( name, subs, leftType, true);
    242247                    }
    243248                }
     
    278283    return pUserProc;
    279284}
    280 const UserProc *ParamImpl::OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType ){
     285const UserProc *ParamImpl::OverloadSolution( const char *name, std::vector<const UserProc *> &subs, const Type &leftType, bool isEnabledReturnType ){
    281286    trace_for_overload( "" );
    282287    trace_for_overload( "■■■■■■■■■■■■■■■■■■" );
    283288    trace_for_overload( "■■■ オーバーロード解決(" << name << ")" );
    284289
    285     const UserProc *result = _OverloadSolution( name, subs, isEnabledReturnType );
     290    const UserProc *result = _OverloadSolution( name, subs, leftType, isEnabledReturnType );
    286291
    287292    trace_for_overload( "■■■ ここまで" );
  • trunk/abdev/BasicCompiler_Common/common.h

    r415 r424  
    250250    std::vector<const UserProc *> &subs,
    251251    const Parameters &params,
    252     const Type &returnType );
     252    const Type &returnType,
     253    const Type &leftType );
    253254
    254255//Debug.cpp
     
    382383void GetCommandToken( char *token, const char *source, int &pos );
    383384void GetCustomToken( char *token, const char *source, int &pos, char delimitation, bool isEscapeSequence );
    384 void SplitGenericClassInstance( const char *fullName, char *className, Jenga::Common::Strings &typeParameters );
     385void SplitGenericClassInstance( const char *fullName, char *className, Jenga::Common::Strings &typeParameters, bool isDefiningClass = false, Jenga::Common::Strings *pTypeParameterBaseClassNames = NULL );
    385386int JumpStatement(const char *source, int &pos);
    386387void Compile(void);
  • trunk/abdev/BasicCompiler_Common/error.cpp

    r412 r424  
    463463    if( varType.IsObject() || calcType.IsObject() )
    464464    {
    465         //いずれかがオブジェクト場合
    466         if( varType.GetBasicType() != calcType.GetBasicType() )
     465        //いずれかがオブジェクトではない場合
     466        if( (!varType.IsObject()) || (!calcType.IsObject()) )
    467467        {
    468468            DifferentTypeError( varType, calcType,3,pszFuncName,ParmNum);
  • trunk/abdev/BasicCompiler_Common/include/Class.h

    r417 r424  
    290290
    291291    // 型パラメータ
     292    const GenericTypes &GetFormalGenericTypes() const
     293    {
     294        return formalGenericTypes;
     295    }
    292296    void AddFormalGenericType( GenericType genericType )
    293297    {
  • trunk/abdev/BasicCompiler_Common/include/Type.h

    r378 r424  
    247247typedef std::vector<Type> Types;
    248248
     249/*!
     250@brief  ジェネリックな型を解決する
     251@param  typeParameter ジェネリック型を指定する。ここに解決後の型が入る。
     252        classType インスタンス化されているオブジェクトの型
     253        pUserProc 現在コンパイル中の関数(ただしクラスメソッドのみ)
     254*/
    249255void ResolveFormalGenericTypeParameter( Type &typeParameter, const Type &classType, const UserProc *pUserProc = NULL );
    250256
  • trunk/abdev/BasicCompiler_Common/src/Class_Collect.cpp

    r409 r424  
    332332            char className[VN_SIZE];
    333333            Jenga::Common::Strings typeParameters;
    334             SplitGenericClassInstance( temporary, className, typeParameters );
     334            Jenga::Common::Strings typeParameterBaseClassNames;
     335            SplitGenericClassInstance( temporary, className, typeParameters, true, &typeParameterBaseClassNames );
    335336
    336337            CClass *pobj_c = const_cast<CClass *>( this->Find(namespaceScopes, className) );
     
    353354            /////////////////////////////////////////////////////////
    354355            // ☆★☆ ジェネリクスサポート ☆★☆
    355             BOOST_FOREACH( const std::string &typeParameter, typeParameters )
    356             {
    357                 pobj_c->AddFormalGenericType( GenericType( typeParameter, Type(DEF_OBJECT,*GetObjectClassPtr()) ) );
     356            for( i2=0; i2<static_cast<int>(typeParameters.size()); i2++ )
     357            {
     358                Type baseType( DEF_OBJECT, *GetObjectClassPtr() );
     359                if( typeParameterBaseClassNames[i2].size() )
     360                {
     361                    if( !compiler.StringToType( typeParameterBaseClassNames[i2], baseType ) )
     362                    {
     363                        SetError(106,typeParameterBaseClassNames[i2],i);
     364                    }
     365                    else if( !baseType.IsObject() )
     366                    {
     367                        SetError(106,typeParameterBaseClassNames[i2],i);
     368                    }
     369                }
     370
     371                pobj_c->AddFormalGenericType( GenericType( typeParameters[i2], baseType ) );
    358372            }
    359373            /////////////////////////////////////////////////////////
     
    527541            char className[VN_SIZE];
    528542            Jenga::Common::Strings typeParameters;
    529             SplitGenericClassInstance( temporary, className, typeParameters );
     543            Jenga::Common::Strings typeParameterBaseClassNames;
     544            SplitGenericClassInstance( temporary, className, typeParameters, true, &typeParameterBaseClassNames );
    530545
    531546            CClass *pobj_c =  const_cast<CClass *>( this->Find(namespaceScopes, className) );
     
    549564            /////////////////////////////////////////////////////////
    550565            // ☆★☆ ジェネリクスサポート ☆★☆
    551             BOOST_FOREACH( const std::string &typeParameter, typeParameters )
    552             {
    553                 pobj_c->AddFormalGenericType( GenericType( typeParameter, Type(DEF_OBJECT,*GetObjectClassPtr()) ) );
     566            for( i2=0; i2<static_cast<int>(typeParameters.size()); i2++ )
     567            {
     568                Type baseType( DEF_OBJECT, *GetObjectClassPtr() );
     569                if( typeParameterBaseClassNames[i2].size() )
     570                {
     571                    if( !compiler.StringToType( typeParameterBaseClassNames[i2], baseType ) )
     572                    {
     573                        SetError(106,typeParameterBaseClassNames[i2],i);
     574                    }
     575                    else if( !baseType.IsObject() )
     576                    {
     577                        SetError(106,typeParameterBaseClassNames[i2],i);
     578                    }
     579                }
     580
     581                pobj_c->AddFormalGenericType( GenericType( typeParameters[i2], baseType ) );
    554582            }
    555583            /////////////////////////////////////////////////////////
  • trunk/abdev/BasicCompiler_Common/src/Compiler.cpp

    r370 r424  
    155155            // コンパイル中クラスにおけるジェネリクス用の型パラメータのとき
    156156            type.SetBasicType( DEF_TYPE_PARAMETER );
    157             type.SetClassPtr( this->GetObjectModule().meta.GetClasses().GetObjectClassPtr() );
     157            type.SetClassPtr( &this->pCompilingClass->GetFormalGenericTypes()[formalTypeIndex].GetType().GetClass() );
    158158            type.SetFormalTypeName( typeName );
    159159            type.SetFormalTypeIndex( formalTypeIndex );
  • trunk/abdev/BasicCompiler_Common/src/Enum.cpp

    r407 r424  
    177177        sprintf(buffer+length,"Class Enum %s\n",enumInfo.GetName().c_str());
    178178        length+=lstrlen(buffer+length);
    179         lstrcpy(buffer+length,"\tInherits EnumBase\n");
     179        sprintf(buffer+length,"\tInherits EnumBase<%s>\n",enumInfo.GetName().c_str());
    180180        length+=lstrlen(buffer+length);
    181181        sprintf(buffer+length,"\tSub %s(value As Long,lpszName As LPSTR)\n",enumInfo.GetName().c_str());
     
    211211        }
    212212
    213         sprintf(buffer+length,"\tFunction Operator or (enumBase As %s) As %s\n",enumInfo.GetName().c_str(),enumInfo.GetName().c_str());
    214         length+=lstrlen(buffer+length);
    215         sprintf(buffer+length,"\t\tReturn New %s(This.value or enumBase.value, \"custom\")\n",enumInfo.GetName().c_str());
    216         length+=lstrlen(buffer+length);
    217         lstrcpy(buffer+length,"\tEnd Function\n");
    218         length+=lstrlen(buffer+length);
    219 
    220         sprintf(buffer+length,"\tFunction Operator and (enumBase As %s) As %s\n",enumInfo.GetName().c_str(),enumInfo.GetName().c_str());
    221         length+=lstrlen(buffer+length);
    222         sprintf(buffer+length,"\t\tReturn New %s(This.value and enumBase.value, \"custom\")\n",enumInfo.GetName().c_str());
    223         length+=lstrlen(buffer+length);
    224         lstrcpy(buffer+length,"\tEnd Function\n");
    225         length+=lstrlen(buffer+length);
    226 
    227         /*
    228         sprintf(buffer+length,"\tOverride Function ToString() As String\n",enumInfo.TypeName);
    229         length+=lstrlen(buffer+length);
    230         lstrcpy(buffer+length,"\t\tSelect Case value\n");
    231         length+=lstrlen(buffer+length);
    232         for(i2=0;i2<enumInfo.iEnumMemberNum;i2++){
    233             CEnumMember *member;
    234             member=enumInfo.ppobj_EnumMember[i2];
    235 
    236             sprintf(buffer+length,"\t\t\tCase %d\n",member->m_value);
    237             length+=lstrlen(buffer+length);
    238             sprintf(buffer+length,"\t\t\t\tReturn \"%s\"\n",member->m_name);
    239             length+=lstrlen(buffer+length);
    240         }
    241         lstrcpy(buffer+length,"\t\tEnd Select\n");
    242         length+=lstrlen(buffer+length);
    243         lstrcpy(buffer+length,"\tEnd Function\n");
    244         length+=lstrlen(buffer+length);
    245 
    246        
    247         sprintf(buffer+length,"\tSub Operator= (ByRef value As %s)\n",enumInfo.TypeName);
    248         length+=lstrlen(buffer+length);
    249         lstrcpy(buffer+length,"\t\tThis.Copy(ByVal VarPtr(value))\n");
    250         length+=lstrlen(buffer+length);
    251         lstrcpy(buffer+length,"\tEnd Sub\n");
    252         length+=lstrlen(buffer+length);
    253 
    254         sprintf(buffer+length,"\tSub Operator= (ByRef value As String)\n",enumInfo.TypeName);
    255         length+=lstrlen(buffer+length);
    256         lstrcpy(buffer+length,"\t\tSelect Case value\n");
    257         length+=lstrlen(buffer+length);
    258         for(i2=0;i2<enumInfo.iEnumMemberNum;i2++){
    259             CEnumMember *member;
    260             member=enumInfo.ppobj_EnumMember[i2];
    261 
    262             sprintf(buffer+length,"\t\t\tCase \"%s\"\n",member->m_name);
    263             length+=lstrlen(buffer+length);
    264             sprintf(buffer+length,"\t\t\t\tThis=%s.%s\n",enumInfo.TypeName,member->m_name);
    265             length+=lstrlen(buffer+length);
    266         }
    267         lstrcpy(buffer+length,"\t\tEnd Select\n");
    268         length+=lstrlen(buffer+length);
    269         lstrcpy(buffer+length,"\tEnd Sub\n");
    270         length+=lstrlen(buffer+length);
    271 
    272         sprintf(buffer+length,"\tSub Operator= (value As Long)\n",enumInfo.TypeName);
    273         length+=lstrlen(buffer+length);
    274         lstrcpy(buffer+length,"\t\tm_Value=value\n");
    275         length+=lstrlen(buffer+length);
    276         lstrcpy(buffer+length,"\tEnd Sub\n");
    277         length+=lstrlen(buffer+length);*/
    278 
    279213        lstrcpy(buffer+length,"End Class\n");
    280214        length+=lstrlen(buffer+length);
  • 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.