Ignore:
Timestamp:
Feb 28, 2008, 9:45:31 PM (16 years ago)
Author:
dai_9181
Message:

プロパティ値として返ってきたオブジェクトインスタンスのインデクサを呼び出す処理をきちんと対応した。

File:
1 edited

Legend:

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

    r402 r403  
    157157        {
    158158            classType = leftType;
     159
     160            if( classType.IsObject() )
     161            {
     162                // 既にuseRegにオブジェクトポインタが格納されており、それに対するインデクサを呼び出す場合
     163                // ※「プロパティ値として返ってきたオブジェクトインスタンスのインデクサを呼び出す」場合にここにくる
     164
     165                //オブジェクトポインタをスタックに入れておく
     166                //push useReg
     167                compiler.codeGenerator.op_push( useReg );
     168            }
    159169        }
    160170        else
    161171        {
    162172            GetMemberType( leftType, VarName, classType, 0, false );
    163         }
    164         if( classType.IsObject() )
    165         {
    166             //オブジェクトポインタをecxにコピー
    167             compiler.codeGenerator.op_mov_RR( REG_ECX, useReg );
    168 
    169             RELATIVE_VAR relativeVar;
    170             relativeVar.dwKind=VAR_DIRECTMEM;
    171 
    172             if( VarName[0] )
     173
     174            if( classType.IsObject() )
    173175            {
     176                // クラス型のメンバに対するインデクサを呼び出す場合
     177
     178                //オブジェクトポインタをecxにコピー
     179                compiler.codeGenerator.op_mov_RR( REG_ECX, useReg );
     180
     181                RELATIVE_VAR relativeVar;
     182                relativeVar.dwKind=VAR_DIRECTMEM;
     183
    174184                if( !_member_offset(
    175185                    true,   //エラー表示あり
     
    190200                compiler.codeGenerator.op_push( REG_EAX );
    191201            }
    192             else
    193             {
    194                 //オブジェクトポインタをスタックに入れておく
    195                 //push ecx
    196                 compiler.codeGenerator.op_push( REG_ECX );
    197             }
    198 
     202        }
     203
     204        if( classType.IsObject() )
     205        {
    199206            char objectFullName[VN_SIZE], dummyArrayElements[VN_SIZE];
    200207            GetArrayElement(termFull,objectFullName,dummyArrayElements);
     
    244251    char methodName[VN_SIZE], lpPtrOffset[VN_SIZE], parameter[VN_SIZE], dummy[1];
    245252    ReferenceKind refType;
     253    bool isParameterInBracket = false;
    246254    lstrcpy( methodName, member );
    247     GetVarFormatString(methodName,parameter,lpPtrOffset,dummy,refType);
     255    GetVarFormatString( methodName, parameter, lpPtrOffset, dummy, refType, &isParameterInBracket );
    248256
    249257    objClass.EnumDynamicMethodsOrInterfaceMethods( methodName, userProcs );
     
    254262        if( pUserProc )
    255263        {
    256             // TODO: この判定処理は暫定(特に[]サーチを行うところが)
    257             if( pUserProc->Params().size() == 0 && parameter[0] && strstr( termFull, "[" ) )
     264            if(
     265                pUserProc->Params().size() == 0             // 仮引数の個数は0
     266                && parameter[0]                             // 実引数は1つ以上
     267                && pUserProc->ReturnType().IsObject()       // 戻り値がクラス型の場合
     268                && isParameterInBracket )                   // 実引数は[]で囲まれている
    258269            {
     270                // プロパティ値として返ってきたオブジェクトインスタンスのインデクサを呼び出す
     271
     272                // まずはプロパティ値を取得
    259273                TermMemberOpe( leftType, baseType, resultType, termFull, termLeft, methodName );
    260274
     275                // 戻り値のオブジェクトインスタンスのインデクサを呼び出す
    261276                char temporary[VN_SIZE], temp2[VN_SIZE];
    262277                sprintf( temporary, "[%s]", parameter );
Note: See TracChangeset for help on using the changeset viewer.