Changeset 334 in dev


Ignore:
Timestamp:
Sep 28, 2007, 12:05:10 AM (17 years ago)
Author:
dai_9181
Message:
 
Location:
trunk/abdev
Files:
10 edited

Legend:

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

    r332 r334  
    296296    userProc.Using();
    297297}
    298 void Opcode_CreateSimpleDelegate( const char *methodInstanceName, const UserProc &userProc )
     298void Opcode_CreateSimpleDelegate( const CClass &dgClass, const char *methodInstanceName, const UserProc &userProc )
    299299{
    300300    /////////////////////////////////////////////////////////////////
     
    339339    compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_EAX, 0, MOD_BASE );
    340340
    341     //push this
     341    //push eax
    342342    compiler.codeGenerator.op_push( REG_EAX );
    343343
     
    347347    /////////////////////////////////////////////////////////////////
    348348
     349    std::vector<const UserProc *> subs;
     350    dgClass.GetStaticMethods().Enum( "_CreateDelegate", subs );
     351
    349352    // call _System_CreateSimpleDynamicDelegate
    350     extern const UserProc *pSub_System_CreateSimpleDynamicDelegate;
    351     compiler.codeGenerator.op_call( pSub_System_CreateSimpleDynamicDelegate );
     353    compiler.codeGenerator.op_call( subs[0] );
    352354}
    353355void Opcode_Func_AddressOf( const char *name, const Type &baseType, bool isCallOn, Type &resultType ){
     
    356358
    357359    const Parameters *pBaseParams = NULL;
    358     bool isDelegate = false;
    359360    if( baseType.IsProcPtr() )
    360361    {
     
    362363        pBaseParams = &compiler.GetObjectModule().meta.GetProcPointers()[baseType.GetIndex()]->Params();
    363364    }
    364     else if( baseType.IsObject() && baseType.GetClass().GetName() == "_SimpleDelegate" )
    365     {
    366         extern const Delegate *pConstructingDelegate;
    367         if( !pConstructingDelegate )
    368         {
    369             SetError();
    370         }
     365    else if( baseType.IsDelegate() )
     366    {
    371367        // 左辺でデリゲートを要求されているとき
    372         pBaseParams = &pConstructingDelegate->Params();
    373 
    374         isDelegate = true;
     368        pBaseParams = &baseType.GetClass().GetDelegate().Params();
    375369    }
    376370
     
    402396    }
    403397
    404     if( isDelegate )
     398    if( baseType.IsDelegate() )
    405399    {
    406400        if( isCallOn )
    407401        {
    408402            // デリゲートのとき
    409             Opcode_CreateSimpleDelegate( name, *pUserProc );
     403            Opcode_CreateSimpleDelegate( baseType.GetClass(), name, *pUserProc );
    410404        }
    411405        resultType = baseType;
  • trunk/abdev/BasicCompiler32/Compile_Object.cpp

    r332 r334  
    1717
    1818
    19     const Delegate *pBackConstructingDelegate;
    20     if( pobj_c->IsDelegate() )
    21     {
    22         // デリゲートの場合はオーバーロード解決用のグローバル変数をセットする
    23         extern const Delegate *pConstructingDelegate;
    24         pBackConstructingDelegate = pConstructingDelegate;
    25         pConstructingDelegate = &pobj_c->GetDelegate();
    26     }
    27 
    28 
    2919/*  //jnzのジャンプ先番地
    3020    extern int obp;
     
    10696        */
    10797    }
    108 
    109     if( pobj_c->IsDelegate() )
    110     {
    111         // デリゲートの場合はオーバーロード解決用のグローバル変数を元に戻す
    112         extern const Delegate *pConstructingDelegate;
    113         pConstructingDelegate = pBackConstructingDelegate;
    114     }
    11598}
    11699void Operator_New( const CClass &classObj, const char *objectSizeStr, const char *parameter, const Type &baseType ){
  • trunk/abdev/BasicCompiler32/Compile_Var.cpp

    r301 r334  
    250250        if(!GetArrayOffset(pMember->GetSubscripts(),array,pMember->GetType())){
    251251            if(isErrorEnabled) SetError(14,member,cp);
     252            return false;
    252253        }
    253254    }
  • trunk/abdev/BasicCompiler32/MakePeHdr.cpp

    r332 r334  
    4242    *pSub_System_GC_free_for_SweepingDelete,
    4343    *pSubStaticMethod_System_TypeBase_InitializeUserTypes,
    44     *pSub_System_CreateSimpleDynamicDelegate,
    4544
    4645    *pSub_allrem,
     
    284283        pSubStaticMethod_System_TypeBase_InitializeUserTypes->ThisIsAutoGenerationProc();
    285284    }
    286 
    287     pSub_System_CreateSimpleDynamicDelegate = GetSubHash( "_System_CreateSimpleDynamicDelegate", TRUE );
    288285
    289286    if( pUserProc_System_CGarbageCollection_RegisterGlobalRoots = GetClassMethod( "_System_CGarbageCollection", "RegisterGlobalRoots" ) ){
  • trunk/abdev/BasicCompiler32/NumOpe.cpp

    r331 r334  
    147147    const int useReg = REG_EAX;
    148148
     149
     150    ////////////////////////////////
     151    // インデクサ(getアクセサ)
     152    ////////////////////////////////
     153    char VarName[VN_SIZE],ArrayElements[VN_SIZE];
     154    GetArrayElement(member,VarName,ArrayElements);
     155    if(ArrayElements[0]){
     156        Type classType;
     157        GetMemberType( leftType, VarName, classType, 0, false );
     158        if( classType.IsObject() )
     159        {
     160            //オブジェクトポインタをecxにコピー
     161            compiler.codeGenerator.op_mov_RR( REG_ECX, useReg );
     162
     163            RELATIVE_VAR relativeVar;
     164            relativeVar.dwKind=VAR_DIRECTMEM;
     165
     166            if( !_member_offset(
     167                true,   //エラー表示あり
     168                false,  //読み込み専用
     169                leftType,
     170                VarName,&relativeVar,classType,0)){
     171                    return false;
     172            }
     173
     174            // オブジェクトメンバのポインタをeaxにコピー
     175            if( !VarToReg( relativeVar, baseType, resultType ) ){
     176                SetError(11,termFull,cp);
     177            }
     178
     179
     180            //オブジェクトポインタをスタックに入れておく
     181            //push eax
     182            compiler.codeGenerator.op_push( REG_EAX );
     183
     184            char objectFullName[VN_SIZE], dummyArrayElements[VN_SIZE];
     185            GetArrayElement(termFull,objectFullName,dummyArrayElements);
     186
     187            CallIndexerGetterProc(/*UseReg,*/classType,objectFullName, ArrayElements,resultType, PROCFLAG_NEW );
     188
     189            compiler.codeGenerator.op_pop();
     190
     191            return true;
     192        }
     193    }
     194
     195
     196    ///////////////////////////////////////////////////////////////////
     197    // メンバを検索
     198    ///////////////////////////////////////////////////////////////////
    149199    if( GetMemberType( leftType, member, resultType, 0, false ) ){
    150200        // メンバが見つかったとき
  • trunk/abdev/BasicCompiler32/Opcode.h

    r331 r334  
    222222int CallOperatorProc(int idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp);
    223223void CallCastOperatorProc(Type &calcType,BOOL bCalcUseHeap,const Type &toType);
    224 void CallIndexerGetterProc( const Type &classType, char *ObjectName, char *Parameter,Type &resultType);
     224void CallIndexerGetterProc( const Type &classType, const char *ObjectName, char *Parameter,Type &resultType, DWORD dwProcFlags = 0 );
    225225
    226226//Compile_Statement.cpp
  • trunk/abdev/BasicCompiler32/OperatorProc.cpp

    r299 r334  
    252252    SetError(-1,"キャスト演算子がオーバーロードされていません。",cp);
    253253}
    254 void CallIndexerGetterProc( const Type &classType, char *ObjectName, char *Parameter,Type &resultType){
     254void CallIndexerGetterProc( const Type &classType, const char *ObjectName, char *Parameter,Type &resultType, DWORD dwProcFlags ){
    255255    std::vector<const UserProc *> subs;
    256256    classType.GetClass().GetMethods().Enum( CALC_ARRAY_GET, subs );
     
    261261    const UserProc *pUserProc = subs[0];
    262262
    263     Opcode_CallProc(Parameter,pUserProc,0,ObjectName);
     263    Opcode_CallProc(Parameter,pUserProc,dwProcFlags,ObjectName);
    264264    resultType = pUserProc->ReturnType();
    265265
  • trunk/abdev/BasicCompiler_Common/BasicCompiler.h

    r332 r334  
    6161
    6262
    63 //デリゲートのベース タイプ インデックス(コンストラクトされるデリゲートのパラメータを参考に、オーバーロードを解決)
    64 const Delegate *pConstructingDelegate;
    65 
    66 
    6763int cp;
    6864
  • trunk/abdev/BasicCompiler_Common/NumOpe_GetType.cpp

    r331 r334  
    301301}
    302302
     303bool GetMemberTermType( const Type &leftType, const Type &baseType, Type &resultType, const char *termFull, const char *termLeft, const char *member )
     304{
     305    ////////////////////////////////
     306    // インデクサ(getアクセサ)
     307    ////////////////////////////////
     308
     309    char VarName[VN_SIZE],ArrayElements[VN_SIZE];
     310    GetArrayElement(member,VarName,ArrayElements);
     311    if(ArrayElements[0]){
     312        Type classType;
     313        GetMemberType( leftType, VarName, classType, 0, false );
     314        if( classType.IsObject() ){
     315            if( !GetReturnTypeOfIndexerGetterProc( classType, resultType ) ){
     316                SetError(1,NULL,cp);
     317                return false;
     318            }
     319
     320            return true;
     321        }
     322    }
     323
     324
     325    ///////////////////////////////////////////////////////////////////
     326    // メンバを検索
     327    ///////////////////////////////////////////////////////////////////
     328    if( GetMemberType( leftType, member, resultType, 0, false ) ){
     329        // メンバが見つかったとき
     330        return true;
     331    }
     332
     333
     334    ///////////////////////////////////////////////////////////////////
     335    // 動的メソッドを検索
     336    ///////////////////////////////////////////////////////////////////
     337    char methodName[VN_SIZE] ,lpPtrOffset[VN_SIZE], dummy[1];
     338    char parameter[VN_SIZE];
     339    ReferenceKind refType;
     340    lstrcpy( methodName, member );
     341    GetVarFormatString(methodName,parameter,lpPtrOffset,dummy,refType);
     342
     343    vector<const UserProc *> userProcs;
     344    leftType.GetClass().GetMethods().Enum( methodName, userProcs );
     345    if(userProcs.size()){
     346        //オーバーロードを解決
     347        const UserProc *pUserProc = OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft);
     348
     349        if( pUserProc ){
     350            resultType = pUserProc->ReturnType();
     351
     352            // 型パラメータを解決
     353            ResolveFormalGenericTypeParameter( resultType, leftType, pUserProc );
     354
     355            return true;
     356        }
     357    }
     358
     359    return false;
     360}
     361
    303362bool GetTermType( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool *pIsClassName )
    304363{
     
    359418        }
    360419
    361 
    362         ///////////////////////////////////////////////////////////////////
    363         // メンバを検索
    364         ///////////////////////////////////////////////////////////////////
    365         if( GetMemberType( leftType, member, resultType, 0, false ) ){
    366             // メンバが見つかったとき
    367             return true;
    368         }
    369 
    370 
    371         ///////////////////////////////////////////////////////////////////
    372         // 動的メソッドを検索
    373         ///////////////////////////////////////////////////////////////////
    374         char methodName[VN_SIZE] ,lpPtrOffset[VN_SIZE];
    375         lstrcpy( methodName, member );
    376         GetVarFormatString(methodName,parameter,lpPtrOffset,member,refType);
    377 
    378         vector<const UserProc *> userProcs;
    379         leftType.GetClass().GetMethods().Enum( methodName, userProcs );
    380         if(userProcs.size()){
    381             //オーバーロードを解決
    382             const UserProc *pUserProc = OverloadSolutionWithStrParam(termFull,userProcs,parameter,termLeft);
    383 
    384             if( pUserProc ){
    385                 resultType = pUserProc->ReturnType();
    386 
    387                 // 型パラメータを解決
    388                 ResolveFormalGenericTypeParameter( resultType, leftType, pUserProc );
    389 
    390                 return true;
    391             }
    392         }
    393 
    394         return false;
     420        return GetMemberTermType( leftType, baseType, resultType, termFull, termLeft, member );
    395421    }
    396422
     
    711737                else if(IsVariableTopChar(term[0])||
    712738                    term[0]=='*'||
    713                     (term[0]=='.'&&IsVariableTopChar(term[1]))){
     739                    (term[0]=='.'&&IsVariableTopChar(term[1])))
     740                {
    714741                    //////////////////
    715742                    // 何らかの識別子
  • trunk/abdev/BasicCompiler_Common/VariableOpe.cpp

    r308 r334  
    491491    }
    492492
     493    if(array[0]){
     494        //配列オフセット
     495        if( pMember->GetSubscripts().size() <= 0 )
     496        {
     497            // 配列ではないメンバに配列指定をした
     498            return false;
     499        }
     500    }
     501    else if( pMember->GetSubscripts().size() > 0 ){
     502        resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR );
     503    }
     504
    493505    if( refType != RefNon ){
    494506        //入れ子構造の場合
     
    499511            0,
    500512            isErrorEnabled);
    501     }
    502 
    503     if( array[0] == 0 && pMember->GetSubscripts().size() > 0 ){
    504         resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR );
    505         return true;
    506513    }
    507514
Note: See TracChangeset for help on using the changeset viewer.