Changeset 370 in dev


Ignore:
Timestamp:
Nov 15, 2007, 3:18:41 AM (16 years ago)
Author:
dai_9181
Message:

COM修飾子に対応。COMインターフェイスを呼び出せるようにした

Location:
trunk/abdev
Files:
30 edited

Legend:

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

    r350 r370  
    326326        if( pobj_c->IsInterface() )
    327327        {
    328             // インターフェイスメソッド呼び出し
     328            // インターフェイス メソッド呼び出し
    329329
    330330            int offset_vtbl = compiler.GetObjectModule().meta.GetClasses().GetInterfaceInfoClassPtr()->GetMemberOffset( "__vtbl" );
     
    349349                SetError();
    350350            }
     351        }
     352        else if( pobj_c->IsComInterface() )
     353        {
     354            // COMインターフェイス メソッド呼び出し
     355
     356            //仮想関数(オブジェクトメソッド)呼び出し
     357            // pObj -> vtbl1 -> func1
     358            //               -> func2
     359            //               -> func3
     360
     361            int vtblMasterListIndex;
     362            pobj_c->GetVtblMasterListIndexAndVtblIndex( pUserProc, vtblMasterListIndex, vtblIndex );
     363
     364            // vtblのポインタを取得
     365            //mov edx,dword ptr[ecx]
     366            compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EDX, REG_ECX, 0, MOD_BASE );
    351367        }
    352368        else
     
    364380
    365381            // vtblマスターリストのポインタを取得
    366             //mov edx,dword ptr[ecx]
    367             compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EDX, REG_ECX, 0, MOD_BASE );
     382            //mov edx,dword ptr[ecx+sizeof(com_vtbl)]
     383            compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EDX, REG_ECX, PTR_SIZE, MOD_BASE_DISP8 );
    368384           
    369385            // vtblのポインタを取得
  • trunk/abdev/BasicCompiler32/Compile_Func.cpp

    r359 r370  
    300300            }
    301301        }
     302        else if( pobj_c->IsComInterface() )
     303        {
     304            // COMインターフェイス メソッド呼び出し
     305
     306            //仮想関数(オブジェクトメソッド)呼び出し
     307            // pObj -> vtbl1 -> func1
     308            //               -> func2
     309            //               -> func3
     310
     311            int vtblMasterListIndex;
     312            pobj_c->GetVtblMasterListIndexAndVtblIndex( &userProc, vtblMasterListIndex, vtblIndex );
     313
     314            // vtblのポインタを取得
     315            //mov edx,dword ptr[ecx]
     316            compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EDX, REG_ECX, 0, MOD_BASE );
     317        }
    302318        else
    303319        {
     
    314330
    315331            // vtblマスターリストのポインタを取得
    316             //mov edx,dword ptr[ecx]
    317             compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EDX, REG_ECX, 0, MOD_BASE );
     332            //mov edx,dword ptr[ecx+sizeof(com_vtbl)]
     333            compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EDX, REG_ECX, PTR_SIZE, MOD_BASE_DISP8 );
    318334           
    319335            // vtblのポインタを取得
  • trunk/abdev/BasicCompiler32/Compile_Object.cpp

    r355 r370  
    218218        && !pClass->IsAbstract() )
    219219    {
    220         // mov ecx,vtblAddress
    221         compiler.codeGenerator.op_mov_RV_vtbl( REG_ECX, pClass );
     220        // mov ecx,com_vtbl
     221        compiler.codeGenerator.op_mov_RV_com_vtbl( REG_ECX, pClass );
    222222
    223223        //mov dword ptr[eax],ecx
    224224        compiler.codeGenerator.op_mov_MR( sizeof(long), REG_ECX, REG_EAX, 0, MOD_BASE );
     225
     226        // mov rcx,vtblAddress
     227        compiler.codeGenerator.op_mov_RV_vtbl( REG_ECX, pClass );
     228
     229        //mov qword ptr[rax+sizeof(com_vtbl)],rcx
     230        compiler.codeGenerator.op_mov_MR(sizeof(long),REG_ECX,REG_EAX,PTR_SIZE,MOD_BASE_DISP8);
    225231
    226232        // 仮想関数になるメソッドに使用チェックをつける
  • trunk/abdev/BasicCompiler32/Compile_ProcOp.cpp

    r365 r370  
    267267        char temporary[1024];
    268268        sprintf( temporary,
    269             "Return New %s(ObjPtr( This ),Get_LONG_PTR( (Get_LONG_PTR( ObjPtr(This) ) + SizeOf(LONG_PTR)*%d) As VoidPtr ) As VoidPtr )",
     269            "Return New %s(ObjPtr( This ),Get_LONG_PTR( (Get_LONG_PTR( ObjPtr(This)+SizeOf(VoidPtr) ) + SizeOf(LONG_PTR)*%d) As VoidPtr ) As VoidPtr )",
    270270            userProc.ReturnType().GetClass().GetName().c_str(),
    271271            vtblMasterListIndex
  • trunk/abdev/BasicCompiler32/Compile_Statement.cpp

    r342 r370  
    115115            FreeTempObject(REG_EBX,&resultType.GetClass());
    116116        }
    117 
    118         //成功
    119         return;
    120     }
    121 
    122     // 失敗
    123     SetError(1, NULL,cp);
     117    }
    124118}
    125119
  • trunk/abdev/BasicCompiler32/Compile_Var.cpp

    r350 r370  
    12151215    //New呼び出し
    12161216    if( type.IsObject()
    1217         && !type.IsInterface()
     1217        && !type.IsInterface() &&  !type.IsComInterface()
    12181218        &&(dwFlags&DIMFLAG_NONCALL_CONSTRACTOR)==0
    12191219        &&InitBuf[0]=='\0')
  • trunk/abdev/BasicCompiler32/NumOpe.cpp

    r363 r370  
    278278    }
    279279
     280    SetError();
     281
    280282    return false;
    281283}
     
    331333        if( !leftType.HasMember() ){
    332334            // メンバを持たない型の場合
     335            if( isProcedureCallOnly )
     336            {
     337                SetError(1,NULL,cp);
     338            }
    333339            return false;
    334340        }
     
    550556    }
    551557
     558    if( isProcedureCallOnly )
     559    {
     560        SetError(3, termLeft, cp );
     561    }
    552562
    553563    return false;
  • trunk/abdev/BasicCompiler32/x86CodeGenerator.cpp

    r357 r370  
    13191319    pNativeCode->PutUserProcSchedule( pUserProc, false );
    13201320}
    1321 void CodeGenerator::op_mov_RV_vtbl( int reg, const CClass *pClass )
     1321void CodeGenerator::op_mov_RV_com_vtbl( int reg, const CClass *pClass )
    13221322{
    13231323    // mov reg,vtblAddress
     
    13271327
    13281328    //DISP32
     1329    pNativeCode->PutComVtblSchedule( pClass );
     1330}
     1331void CodeGenerator::op_mov_RV_vtbl( int reg, const CClass *pClass )
     1332{
     1333    // mov reg,vtblAddress
     1334
     1335    //オペコード、レジスタ
     1336    pNativeCode->Put( (char)(0xB8|REGISTER_OPERAND(reg)) );
     1337
     1338    //DISP32
    13291339    pNativeCode->PutVtblSchedule( pClass );
    13301340}
  • trunk/abdev/BasicCompiler64/CodeGenerator.cpp

    r357 r370  
    17331733    pNativeCode->PutUserProcSchedule( pUserProc, false );
    17341734}
     1735void CodeGenerator::op_mov_RV_com_vtbl( int reg, const CClass *pClass )
     1736{
     1737    // mov reg,com_vtblAddress
     1738
     1739    //オペコード、レジスタ
     1740    pNativeCode->Put( (char)(0xB8|REGISTER_OPERAND(reg)) );
     1741
     1742    //DISP32
     1743    pNativeCode->PutComVtblSchedule( pClass );
     1744}
    17351745void CodeGenerator::op_mov_RV_vtbl( int reg, const CClass *pClass )
    17361746{
  • trunk/abdev/BasicCompiler64/Compile_Calc.cpp

    r331 r370  
    208208    //変数アドレスを取得
    209209    RELATIVE_VAR VarRelativeVar;
    210     if(!GetVarOffsetReadWrite(
     210    bool result = GetVarOffsetReadWrite(
    211211        variable,
    212212        &VarRelativeVar,
    213         varType)) return;
     213        varType);
    214214
    215215    //レジスタのブロッキングを解除
    216216    pobj_BlockReg->clear();
     217
     218    if( !result )
     219    {
     220        return;
     221    }
    217222
    218223    if(varType.GetBasicType()&FLAG_PTR){
  • trunk/abdev/BasicCompiler64/Compile_CallProc.cpp

    r350 r370  
    359359        if( pobj_c->IsInterface() )
    360360        {
    361             // インターフェイスメソッド呼び出し
     361            // インターフェイス メソッド呼び出し
    362362
    363363            int offset_vtbl = compiler.GetObjectModule().meta.GetClasses().GetInterfaceInfoClassPtr()->GetMemberOffset( "__vtbl" );
     
    380380            }
    381381        }
     382        else if( pobj_c->IsComInterface() )
     383        {
     384            // COMインターフェイス メソッド呼び出し
     385
     386            //仮想関数(オブジェクトメソッド)呼び出し
     387            // pObj -> vtbl1 -> func1
     388            //               -> func2
     389            //               -> func3
     390
     391            int vtblMasterListIndex;
     392            pobj_c->GetVtblMasterListIndexAndVtblIndex( pUserProc, vtblMasterListIndex, vtblIndex );
     393
     394            // vtblのポインタを取得
     395            //mov r11,qword ptr[rcx]
     396            compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RCX,0,MOD_BASE);        }
    382397        else
    383398        {
     
    394409
    395410            // vtblマスターリストのポインタを取得
    396             //mov r11,qword ptr[rcx]
    397             compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RCX,0,MOD_BASE);
     411            //mov r11,qword ptr[rcx+sizeof(com_vtbl)]
     412            compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RCX,PTR_SIZE,MOD_BASE_DISP8);
    398413
    399414            // vtblのポインタを取得
  • trunk/abdev/BasicCompiler64/Compile_Func.cpp

    r359 r370  
    144144            }
    145145        }
     146        else if( pobj_c->IsComInterface() )
     147        {
     148            //仮想関数(オブジェクトメソッド)
     149            // pObj -> vtbl1 -> func1
     150            //               -> func2
     151            //               -> func3
     152
     153            int vtblMasterListIndex;
     154            pobj_c->GetVtblMasterListIndexAndVtblIndex( &userProc, vtblMasterListIndex, vtblIndex );
     155
     156            // vtblのポインタを取得
     157            //mov r11,qword ptr[rcx]
     158            compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RCX,0,MOD_BASE);
     159        }
    146160        else
    147161        {
     
    158172
    159173            // vtblマスターリストのポインタを取得
    160             //mov r11,qword ptr[rcx]
    161             compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RCX,0,MOD_BASE);
     174            //mov r11,qword ptr[rcx+sizeof(com_vtbl)]
     175            compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RCX,PTR_SIZE,MOD_BASE_DISP8);
    162176
    163177            // vtblのポインタを取得
  • trunk/abdev/BasicCompiler64/Compile_Object.cpp

    r355 r370  
    212212        && !pClass->IsAbstract() )
    213213    {
     214        // mov rcx,com_vtbl
     215        compiler.codeGenerator.op_mov_RV_com_vtbl( REG_RCX, pClass );
     216
     217        //mov qword ptr[rax],rcx
     218        compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RCX,REG_RAX,0,MOD_BASE);
     219
    214220        // mov rcx,vtblAddress
    215221        compiler.codeGenerator.op_mov_RV_vtbl( REG_RCX, pClass );
    216222
    217         //mov qword ptr[rax],rcx
    218         compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RCX,REG_RAX,0,MOD_BASE);
     223        //mov qword ptr[rax+sizeof(com_vtbl)],rcx
     224        compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RCX,REG_RAX,PTR_SIZE,MOD_BASE_DISP8);
    219225
    220226
  • trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp

    r366 r370  
    189189        char temporary[1024];
    190190        sprintf( temporary,
    191             "Return New %s(ObjPtr( This ),Get_LONG_PTR( (Get_LONG_PTR( ObjPtr(This) ) + SizeOf(LONG_PTR)*%d) As VoidPtr ) As VoidPtr )",
     191            "Return New %s(ObjPtr( This ),Get_LONG_PTR( (Get_LONG_PTR( ObjPtr(This)+SizeOf(VoidPtr) ) + SizeOf(LONG_PTR)*%d) As VoidPtr ) As VoidPtr )",
    192192            userProc.ReturnType().GetClass().GetName().c_str(),
    193193            vtblMasterListIndex
  • trunk/abdev/BasicCompiler64/Compile_Statement.cpp

    r345 r370  
    9696    pobj_reg=new CRegister(REG_RAX);
    9797
     98    if( strstr(leftTerm,"赤"))
     99    {
     100        int test=0;
     101    }
     102
    98103    Type resultType;
    99104    bool isLiteral;
     
    116121            FreeTempObject(REG_R14,&resultType.GetClass());
    117122        }
    118 
    119         //成功
    120         return;
    121     }
    122 
    123     // 失敗
    124     SetError(1, NULL,cp);
     123    }
    125124}
    126125
  • trunk/abdev/BasicCompiler64/Compile_Var.cpp

    r350 r370  
    12281228    //New呼び出し
    12291229    if( type.IsObject()
    1230         && !type.IsInterface()
     1230        && !type.IsInterface() &&  !type.IsComInterface()
    12311231        &&(dwFlags&DIMFLAG_NONCALL_CONSTRACTOR)==0
    12321232        &&InitBuf[0]=='\0')
  • trunk/abdev/BasicCompiler64/NumOpe.cpp

    r368 r370  
    291291    }
    292292
     293    SetError();
     294
    293295    return false;
    294296}
     
    344346        if( !leftType.HasMember() ){
    345347            // メンバを持たない型の場合
     348            if( isProcedureCallOnly )
     349            {
     350                SetError(1,NULL,cp);
     351            }
    346352            return false;
    347353        }
     
    580586    }
    581587
     588    if( isProcedureCallOnly )
     589    {
     590        SetError(3, termLeft, cp );
     591    }
    582592
    583593    return false;
  • trunk/abdev/BasicCompiler_Common/VariableOpe.cpp

    r368 r370  
    850850        if( !compiler.StringToType( temporary, type ) ){
    851851            SetError(3,temporary,cp);
    852             type.SetBasicType( DEF_LONG );
     852            return false;
    853853        }
    854854
  • trunk/abdev/BasicCompiler_Common/error.cpp

    r366 r370  
    207207    if(num==133) lstrcpy(msg,"Thisに代入はできません。");
    208208    if(num==134) lstrcpy( msg,"ObjPtr関数にはオブジェクト インスタンス以外を指定できません。" );
    209     if(num==135) lstrcpy( msg, "クラスまたはインターフェイス以外の型を継承元として指定することはできません。" );
     209    if(num==135) lstrcpy( msg, "クラス以外の型を継承元として指定することはできません。" );
    210210    if(num==136) lstrcpy( msg, "非仮想関数に対してオーバーライドしようとしました。" );
    211211    if(num==137) lstrcpy(msg,"ImplementsはClass定義内の先頭に記述する必要があります。");
     
    322322
    323323            i2=0;
     324
     325            if( num == 300 )
     326            {
     327                // 内部エラー
     328                i2=0;
     329            }
    324330        }
    325331
  • trunk/abdev/BasicCompiler_Common/include/Class.h

    r369 r370  
    122122        Class,
    123123        Interface,
     124        ComInterface,
    124125        Enum,
    125126        Delegate,
     
    204205        , vtblNum( 0 )
    205206        , vtbl_offset( -1 )
     207        , comVtblOffset( 0 )
    206208        , isCompilingConstructor( false )
    207209        , isCompilingDestructor( false )
     
    221223        , vtblNum( 0 )
    222224        , vtbl_offset( -1 )
     225        , comVtblOffset( 0 )
    223226        , isCompilingConstructor( false )
    224227        , isCompilingDestructor( false )
     
    339342    bool IsClass() const;
    340343    bool IsInterface() const;
     344    bool IsComInterface() const;
    341345    bool IsEnum() const;
    342346    bool IsDelegate() const;
     
    516520private:
    517521    long vtbl_offset;
     522    long comVtblOffset;
    518523    long vtblMasterListOffset;
    519524    std::vector<long> vtblMasterList;
     
    521526    void GetVtblMasterListIndexAndVtblIndex( const UserProc *pUserProc, int &vtblMasterListIndex, int &vtblIndex ) const;
    522527    int GetVtblMasterListIndex( const CClass *pClass ) const;
     528    long GetComVtblOffset() const;
    523529    long GetVtblMasterListOffset() const;
    524530    void GenerateVTableMasterList( const std::vector<long> &vtableMasterList, long &offset );
  • trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h

    r364 r370  
    374374    void op_ret();
    375375    void op_addressof( int reg, const UserProc *pUserProc );
     376    void op_mov_RV_com_vtbl( int reg, const CClass *pClass );
    376377    void op_mov_RV_vtbl( int reg, const CClass *pClass );
    377378
     
    455456    void op_ret( short stackFrameSize );
    456457    void op_addressof( int reg, const UserProc *pUserProc );
     458    void op_mov_RV_com_vtbl( int reg, const CClass *pClass );
    457459    void op_mov_RV_vtbl( int reg, const CClass *pClass );
    458460#endif
  • trunk/abdev/BasicCompiler_Common/include/NativeCode.h

    r357 r370  
    2424        AddressOf,      // ユーザ定義関数位置スケジュール
    2525        DllProc,        // DLL関数位置スケジュール
     26        ComVtbl,        // com_vtblスケジュール
    2627        Vtbl,           // vtblスケジュール
    2728        TypeInfo,       // TypeInfoスケジュール
     
    5960            ar & boost::serialization::make_nvp("pDllProc", const_cast<::DllProc *&>(pDllProc));
    6061            break;
     62        case ComVtbl:
    6163        case Vtbl:
    6264        case TypeInfo:
     
    9193    {
    9294    }
    93     Schedule( const ::CClass *pClass, long offset )
    94         : type( Schedule::Vtbl )
    95         , offset( offset )
    96         , pClass( pClass )
    97     {
    98     }
    9995    Schedule( Type type, const ::CClass *pClass, long offset )
    10096        : type( type )
     
    10298        , offset( offset )
    10399    {
     100        if( !( type == Schedule::ComVtbl || type == Schedule::Vtbl || type == Schedule::TypeInfo ) )
     101        {
     102            DebugBreak();
     103        }
    104104    }
    105105    ~Schedule()
     
    137137    const ::CClass &GetClass() const
    138138    {
    139         if( !( type == Schedule::Vtbl || type == Schedule::TypeInfo ) )
     139        if( !( type == Schedule::ComVtbl || type == Schedule::Vtbl || type == Schedule::TypeInfo ) )
    140140        {
    141141            SetError();
     
    293293    void PutCatchAddressSchedule( const UserProc *pUserProc, long codePos );
    294294    void PutDllProcSchedule( const DllProc *pDllProc );
     295    void PutComVtblSchedule( const CClass *pClass );
    295296    void PutVtblSchedule( const CClass *pClass );
    296297
  • trunk/abdev/BasicCompiler_Common/include/Type.h

    r350 r370  
    190190    bool IsDelegate() const;
    191191    bool IsInterface() const;
     192    bool IsComInterface() const;
    192193
    193194    // オブジェクトや構造体など、メンバを持つ型かどうかを判別する
  • trunk/abdev/BasicCompiler_Common/src/Class.cpp

    r369 r370  
    116116    return classType == CClass::Interface;
    117117}
     118bool CClass::IsComInterface() const
     119{
     120    return classType == CClass::ComInterface;
     121}
    118122bool CClass::IsEnum() const
    119123{
     
    241245        }
    242246
    243         if( pInheritsClass->IsInterface() ){
    244             // インターフェイスはあとで継承する
    245         }
    246         else if( pInheritsClass->IsClass() ){
     247        if( pInheritsClass->IsClass() ){
    247248            // クラスを継承する
    248249            isInheritsClass = true;
     
    253254        }
    254255        else{
    255             SmoothieException::Throw(135,NULL,nowLine);
     256            SetError(135,pInheritsClass->GetFullName().c_str(),nowLine);
    256257            return false;
    257258        }
     
    268269            return false;
    269270        }
    270     }
    271 
    272     i=0;
    273     while( true ){
    274 
    275         char temporary[VN_SIZE];
    276         for( int i2=0;; i++, i2++ ){
    277             if( inheritNames[i] == '\0' || inheritNames[i] == ',' ){
    278                 temporary[i2] = 0;
    279                 break;
    280             }
    281             temporary[i2] = inheritNames[i];
    282         }
    283 
    284         char className[VN_SIZE];
    285         Jenga::Common::Strings typeParameters;
    286         SplitGenericClassInstance( temporary, className, typeParameters );
    287 
    288         //継承元クラスを取得
    289         const CClass *pInheritsClass = compiler.GetObjectModule().meta.GetClasses().Find(className);
    290         if( !pInheritsClass ){
    291             SmoothieException::Throw(106,className,nowLine);
    292             return false;
    293         }
    294 
    295         if( pInheritsClass->IsInterface() ){
    296             // インターフェイスを継承する
    297             if( !InheritsInterface( *pInheritsClass, nowLine ) ){
    298                 return false;
    299             }
    300         }
    301         else if( pInheritsClass->IsClass() ){
    302             // クラスはさっき継承した
    303         }
    304         else{
    305             SmoothieException::Throw(135,NULL,nowLine);
    306             return false;
    307         }
    308 
    309         if( inheritNames[i] == '\0' ){
    310             break;
    311         }
    312         i++;
    313271    }
    314272
     
    388346    }
    389347
     348    if( this->IsInterface() && inheritsClass.IsComInterface() )
     349    {
     350        // COMインターフェイスを継承した場合はCOMインターフェイスにする
     351        this->SetClassType( CClass::ComInterface );
     352    }
     353
    390354    return true;
    391355}
    392 bool CClass::InheritsInterface( const CClass &inheritsInterface, int nowLine ){
    393 
    394     //ループ継承でないかをチェック
    395     if(pobj_LoopRefCheck->check(inheritsInterface)){
    396         SmoothieException::Throw(123,inheritsInterface.GetName(),nowLine);
    397         return false;
    398     }
    399 
    400     if( !inheritsInterface.IsReady() ){
    401         //継承先が読み取られていないとき
    402         pobj_LoopRefCheck->add(this->GetName().c_str());
    403         compiler.GetObjectModule().meta.GetClasses().GetClass_recur(inheritsInterface.GetName().c_str());
    404         pobj_LoopRefCheck->del(this->GetName().c_str());
    405     }
    406 
    407     //メソッドをコピー
    408     BOOST_FOREACH( const CMethod *pBaseMethod, inheritsInterface.GetDynamicMethods() ){
    409         CMethod *pMethod = new DynamicMethod( *pBaseMethod );
    410 
    411         // アクセシビリティ
    412         if(pBaseMethod->GetAccessibility() == Prototype::Private){
    413             pMethod->SetAccessibility( Prototype::None );
    414         }
    415         else{
    416             pMethod->SetAccessibility( pBaseMethod->GetAccessibility() );
    417         }
    418 
    419         //pobj_Inherits
    420         // ※継承元のClassIndexをセット(入れ子継承を考慮する)
    421         if(pBaseMethod->GetInheritsClassPtr()==0){
    422             pMethod->SetInheritsClassPtr( &inheritsInterface );
    423         }
    424         else{
    425             pMethod->SetInheritsClassPtr( pBaseMethod->GetInheritsClassPtr() );
    426         }
    427 
    428         GetDynamicMethods().push_back( pMethod );
    429     }
    430 
    431     //interfaces.push_back( Interface( &inheritsInterface, vtblNum ) );
    432 
    433     //仮想関数の数
    434     AddVtblNum( inheritsInterface.GetVtblNum() );
    435 
    436     return true;
    437 }
    438356
    439357bool CClass::Implements( const CClass &interfaceClass, int nowLine )
    440358{
    441     if( !interfaceClass.IsInterface() )
     359    if( !interfaceClass.IsInterface() && !interfaceClass.IsComInterface() )
    442360    {
    443361        // インターフェイスではないとき
     
    477395    // キャストメソッドを追加(内部コードは自動生成すること)
    478396    /////////////////////////////////////////////////////////////////
     397    if( interfaceClass.IsInterface() )
    479398    {
    480399        // Function Operator() As ITest
     
    793712    int i2;
    794713
    795     //仮想関数が存在する場合は関数リストへのポインタのサイズを追加
    796     int offset = IsExistVirtualFunctions() ? PTR_SIZE : 0;
     714    //仮想関数が存在する場合はvtbl及びvtblMasterListへのポインタのサイズを追加
     715    int offset = IsExistVirtualFunctions() ? PTR_SIZE*2 : 0;
    797716
    798717    int alignment = 1;
     
    944863    return 0;
    945864}
     865long CClass::GetComVtblOffset() const
     866{
     867    return comVtblOffset;
     868}
    946869long CClass::GetVtblMasterListOffset() const
    947870{
     
    992915
    993916        pInterface->SetVtblOffset( tempVtblOffset );
     917
     918        if( pInterface->GetClass().IsComInterface() )
     919        {
     920            if( this->comVtblOffset )
     921            {
     922                SetError();
     923            }
     924            this->comVtblOffset = tempVtblOffset;
     925        }
    994926    }
    995927
     
    14451377            pobj_c->SetConstructorMemberSubIndex( -1 );
    14461378            pobj_c->SetDestructorMemberSubIndex( -1 );
     1379
     1380            if( memcmp( basbuf+i+1, "__COM", 5 ) == 0 && IsCommandDelimitation( basbuf[i+1+5] ) )
     1381            {
     1382                // COMインターフェイス
     1383                pobj_c->SetClassType( CClass::ComInterface );
     1384
     1385                i += 6;
     1386            }
    14471387
    14481388            if(basbuf[i+1]==1&&basbuf[i+2]==ESC_INHERITS){
  • trunk/abdev/BasicCompiler_Common/src/Compiler.cpp

    r318 r370  
    3636        if( !pGenericClass )
    3737        {
    38             extern int cp;
    39             SetError(106, className, cp );
    4038            return false;
    4139        }
  • trunk/abdev/BasicCompiler_Common/src/DataTable.cpp

    r355 r370  
    8484    this->lastMadeConstObjectDataTableOffset = dataTableOffset;
    8585
     86    // com_vtblスケジュール
     87    this->schedules.push_back( Schedule( Schedule::ComVtbl, &objClass, dataTableOffset ) );
     88
    8689    // vtblスケジュール
    87     this->schedules.push_back( Schedule( &objClass, dataTableOffset ) );
     90    this->schedules.push_back( Schedule( Schedule::Vtbl, &objClass, dataTableOffset + PTR_SIZE ) );
    8891
    8992    // TypeInfoスケジュール
     
    235238
    236239    // スケジューリング
    237     this->schedules.push_back( Schedule( &strClass, headOffset ) );
     240    this->schedules.push_back( Schedule( Schedule::ComVtbl, &strClass, headOffset ) );
     241    this->schedules.push_back( Schedule( Schedule::Vtbl, &strClass, headOffset + PTR_SIZE ) );
    238242    this->schedules.push_back( Schedule( Schedule::TypeInfo, &strClass, headOffset + offsetForTypeInfo ) );
    239243    this->schedules.push_back( Schedule( Schedule::DataTable, headOffset + offsetForChars ) );
  • trunk/abdev/BasicCompiler_Common/src/Linker.cpp

    r361 r370  
    165165    BOOST_FOREACH( const Schedule &schedule, nativeCode.GetSchedules() )
    166166    {
     167        if( schedule.GetType() == Schedule::ComVtbl )
     168        {
     169            LONG_PTR vtblOffset = schedule.GetClass().GetComVtblOffset();
     170
     171            nativeCode.Overwrite(
     172                schedule.GetOffset(),
     173                static_cast<long>( vtblOffset + imageBase + dataSectionBaseOffset )
     174            );
     175        }
     176
    167177        if( schedule.GetType() == Schedule::Vtbl )
    168178        {
     
    178188    BOOST_FOREACH( const Schedule &schedule, dataTable.schedules )
    179189    {
     190        if( schedule.GetType() == Schedule::ComVtbl )
     191        {
     192            LONG_PTR vtblOffset = schedule.GetClass().GetComVtblOffset();
     193
     194#ifdef _WIN64
     195            dataTable.OverwriteInt64(
     196                schedule.GetOffset(),
     197                vtblOffset + imageBase + dataSectionBaseOffset
     198            );
     199#else
     200            dataTable.Overwrite(
     201                schedule.GetOffset(),
     202                vtblOffset + imageBase + dataSectionBaseOffset
     203            );
     204#endif
     205        }
     206
    180207        if( schedule.GetType() == Schedule::Vtbl )
    181208        {
  • trunk/abdev/BasicCompiler_Common/src/Method.cpp

    r353 r370  
    155155            if( !pMethod->GetUserProc().IsUsing() )
    156156            {
    157                 ts((char *)pMethod->GetUserProc().GetFullName().c_str());
     157                //ts((char *)pMethod->GetUserProc().GetFullName().c_str());
    158158            }
    159159            pMethod->GetUserProc().Using();
  • trunk/abdev/BasicCompiler_Common/src/NativeCode.cpp

    r364 r370  
    9595}
    9696
     97void NativeCode::PutComVtblSchedule( const CClass *pClass )
     98{
     99    schedules.push_back( Schedule( Schedule::ComVtbl, pClass, GetSize() ) );
     100
     101    Put( (long)0 );
     102}
     103
    97104void NativeCode::PutVtblSchedule( const CClass *pClass )
    98105{
    99     schedules.push_back( Schedule( pClass, GetSize() ) );
     106    schedules.push_back( Schedule( Schedule::Vtbl, pClass, GetSize() ) );
    100107
    101108    Put( (long)0 );
  • trunk/abdev/BasicCompiler_Common/src/Type.cpp

    r350 r370  
    452452{
    453453    return ( IsObject() && GetClass().IsInterface() );
     454}
     455bool Type::IsComInterface() const
     456{
     457    return ( IsObject() && GetClass().IsComInterface() );
    454458}
    455459
Note: See TracChangeset for help on using the changeset viewer.